Stashbox by Peter Csajtai

<PackageReference Include="Stashbox" Version="3.6.1-preview-633" />

 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.ImplementationTypeInfo); return true; } public bool ShouldIncrementWeight(TypeInformation typeInformation, ServiceRegistration registration, ResolutionContext resolutionContext) { return false; } } }