Stashbox by Peter Csajtai

<PackageReference Include="Stashbox" Version="3.1.1-preview-549" />

 ConditionRule

using Stashbox.Resolution; namespace Stashbox.Registration.SelectionRules { internal class ConditionRule : IRegistrationSelectionRule { public bool IsValidForCurrentRequest(TypeInformation typeInformation, ServiceRegistration registration, ResolutionContext resolutionContext) { return true; } public bool ShouldIncrementWeight(TypeInformation typeInformation, ServiceRegistration registration, ResolutionContext resolutionContext) { if (registration.HasCondition) return registration.IsUsableForCurrentContext(typeInformation); return false; } } }