Stashbox by Peter Csajtai

<PackageReference Include="Stashbox" Version="3.5.1-preview-627" />

 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; } } }