Stashbox by Peter Csajtai

<PackageReference Include="Stashbox" Version="2.8.8" />

 FluentServiceConfigurator<TService, TConfigurator>

public class FluentServiceConfigurator<TService, TConfigurator> : FluentServiceConfigurator<TConfigurator>, IFluentServiceConfigurator<TService, TConfigurator>, IFluentServiceConfigurator<TConfigurator>, IBaseFluentConfigurator<TConfigurator> where TConfigurator : FluentServiceConfigurator<TService, TConfigurator>
Represents the generic fluent service registration api.
using System; using System.Linq.Expressions; namespace Stashbox.Registration.Fluent { public class FluentServiceConfigurator<TService, TConfigurator> : FluentServiceConfigurator<TConfigurator>, IFluentServiceConfigurator<TService, TConfigurator>, IFluentServiceConfigurator<TConfigurator>, IBaseFluentConfigurator<TConfigurator> where TConfigurator : FluentServiceConfigurator<TService, TConfigurator> { internal FluentServiceConfigurator(Type serviceType, Type implementationType) : base(serviceType, implementationType) { } public TConfigurator InjectMember<TResult>(Expression<Func<TService, TResult>> expression, object dependencyName = null) { MemberExpression memberExpression; if ((memberExpression = (expression.Body as MemberExpression)) != null) { base.Context.InjectionMemberNames.Add(memberExpression.Member.Name, dependencyName); return (TConfigurator)this; } throw new ArgumentException("The expression must be a member expression (Property or Field)", "expression"); } public TConfigurator WithDependencyBinding<TDependency>(object dependencyName) { return base.WithDependencyBinding(typeof(TDependency), dependencyName); } public TConfigurator WithFinalizer(Action<TService> finalizer) { base.Context.Finalizer = finalizer; return (TConfigurator)this; } public TConfigurator WithInitializer(Action<TService, IDependencyResolver> initializer) { base.Context.Initializer = initializer; return (TConfigurator)this; } public TConfigurator AsServiceAlso<TAdditionalService>() { base.AsServiceAlso(typeof(TAdditionalService)); return (TConfigurator)this; } } }