Stashbox by Peter Csajtai

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

 BaseFluentServiceConfigurator<TService, TImplementation, TConfigurator>

public class BaseFluentServiceConfigurator<TService, TImplementation, TConfigurator> : BaseFluentConfigurator<TConfigurator> where TConfigurator : BaseFluentServiceConfigurator<TService, TImplementation, TConfigurator>
Represents the base of the generic fluent registration api.
using System; using System.Linq.Expressions; namespace Stashbox.Registration.Fluent { public class BaseFluentServiceConfigurator<TService, TImplementation, TConfigurator> : BaseFluentConfigurator<TConfigurator> where TConfigurator : BaseFluentServiceConfigurator<TService, TImplementation, TConfigurator> { internal BaseFluentServiceConfigurator(Type serviceType, Type implementationType) : base(serviceType, implementationType) { } public TConfigurator InjectMember<TResult>(Expression<Func<TImplementation, TResult>> expression, object dependencyName = null) { MemberExpression memberExpression = expression.Body as MemberExpression; if (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 WithFinalizer(Action<TImplementation> finalizer) { base.Context.Finalizer = finalizer; return (TConfigurator)this; } public TConfigurator WithInitializer(Action<TImplementation, IDependencyResolver> initializer) { base.Context.Initializer = initializer; return (TConfigurator)this; } public TConfigurator WithFactory(Func<TService> singleFactory, bool isCompiledLambda = false) { base.Context.SingleFactory = singleFactory; base.Context.IsFactoryDelegateACompiledLambda = isCompiledLambda; return (TConfigurator)this; } public TConfigurator WithFactory(Func<IDependencyResolver, TService> containerFactory, bool isCompiledLambda = false) { base.Context.ContainerFactory = containerFactory; base.Context.IsFactoryDelegateACompiledLambda = isCompiledLambda; return (TConfigurator)this; } } }