Stashbox by Peter Csajtai

<PackageReference Include="Stashbox" Version="4.2.0-preview-685" />

 OpenGenericRule

using Stashbox.Resolution; using System; namespace Stashbox.Registration.SelectionRules { internal class OpenGenericRule : IRegistrationSelectionRule { public bool IsValidForCurrentRequest(TypeInformation typeInformation, ServiceRegistration registration, ResolutionContext resolutionContext) { if (typeInformation.Type.IsClosedGenericType()) return typeInformation.Type.SatisfiesGenericConstraintsOf(registration.ImplementationType); return true; } public bool ShouldIncrementWeight(TypeInformation typeInformation, ServiceRegistration registration, ResolutionContext resolutionContext) { return false; } } }