Stashbox by Peter Csajtai

<PackageReference Include="Stashbox" Version="3.2.8-preview-596" />

 FluentServiceConfigurator<TConfigurator>

public class FluentServiceConfigurator<TConfigurator> : BaseFluentConfigurator<TConfigurator> where TConfigurator : FluentServiceConfigurator<TConfigurator>
Represents the fluent service registration api.
using Stashbox.Utils.Data; using System; using System.Linq; namespace Stashbox.Registration.Fluent { public class FluentServiceConfigurator<TConfigurator> : BaseFluentConfigurator<TConfigurator> where TConfigurator : FluentServiceConfigurator<TConfigurator> { internal FluentServiceConfigurator(Type serviceType, Type implementationType) : base(serviceType, implementationType) { } internal FluentServiceConfigurator(Type serviceType, Type implementationType, RegistrationContext registrationContext) : base(serviceType, implementationType, registrationContext) { } public TConfigurator WithName(object name) { base.Context.Name = name; return (TConfigurator)this; } public TConfigurator DefinesScope(object scopeName = null) { base.Context.DefinedScopeName = (scopeName ?? base.ImplementationType); return (TConfigurator)this; } public TConfigurator AsImplementedTypes() { base.Context.AdditionalServiceTypes = EnumerableExtensions.AsExpandableArray<Type>(Enumerable.Concat<Type>(base.ImplementationType.GetRegisterableInterfaceTypes(), base.ImplementationType.GetRegisterableBaseTypes())); return (TConfigurator)this; } public TConfigurator AsServiceAlso<TAdditionalService>() { return this.AsServiceAlso(typeof(TAdditionalService)); } public TConfigurator AsServiceAlso(Type serviceType) { if (!base.ImplementationType.Implements(serviceType)) throw new ArgumentException($"""{base.ImplementationType}""{serviceType}"""); ((ExpandableArray<Type>)base.Context.AdditionalServiceTypes).Add(serviceType); return (TConfigurator)this; } } }