Stashbox by Peter Csajtai

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

 ConditionRule

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