Stashbox by Peter Csajtai

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

 ContainerConfigurator

public class ContainerConfigurator
using Stashbox.Lifetime; using Stashbox.Registration.Fluent; using System; using System.Collections.Generic; using System.Linq.Expressions; using System.Reflection; using System.Runtime.CompilerServices; namespace Stashbox.Configuration { [System.Runtime.CompilerServices.NullableContext(1)] [System.Runtime.CompilerServices.Nullable(0)] public class ContainerConfigurator { public ContainerConfiguration ContainerConfiguration { get; } [System.Runtime.CompilerServices.NullableContext(2)] internal ContainerConfigurator(ContainerConfiguration containerConfiguration = null) { ContainerConfiguration = (containerConfiguration ?? new ContainerConfiguration()); } public ContainerConfigurator WithDisposableTransientTracking(bool enabled = true) { ContainerConfiguration.TrackTransientsForDisposalEnabled = enabled; return this; } public ContainerConfigurator WithRegistrationBehavior(Rules.RegistrationBehavior registrationBehavior) { ContainerConfiguration.RegistrationBehavior = registrationBehavior; return this; } [Obsolete("Please use parameterized factory registrations to avoid circular dependencies across delegates. `.Register<Service>(options => options.WithFactory<Dependency>(dependency => new Service(dependency)))`")] public ContainerConfigurator WithRuntimeCircularDependencyTracking(bool enabled = true) { ContainerConfiguration.RuntimeCircularDependencyTrackingEnabled = enabled; return this; } public ContainerConfigurator WithDefaultValueInjection(bool enabled = true) { ContainerConfiguration.DefaultValueInjectionEnabled = enabled; return this; } public ContainerConfigurator WithUnknownTypeResolution([System.Runtime.CompilerServices.Nullable(new byte[] { 2, 1 })] Action<UnknownRegistrationConfigurator> configurator = null, bool enabled = true) { ContainerConfiguration.UnknownTypeResolutionEnabled = enabled; ContainerConfiguration.UnknownTypeConfigurator = configurator; return this; } public ContainerConfigurator WithAutoMemberInjection(Rules.AutoMemberInjectionRules rule = Rules.AutoMemberInjectionRules.PropertiesWithPublicSetter, [System.Runtime.CompilerServices.Nullable(new byte[] { 2, 1 })] Func<MemberInfo, bool> filter = null, bool enabled = true) { ContainerConfiguration.AutoMemberInjectionEnabled = enabled; ContainerConfiguration.AutoMemberInjectionRule = rule; ContainerConfiguration.AutoMemberInjectionFilter = filter; return this; } public ContainerConfigurator WithConstructorSelectionRule(Func<IEnumerable<ConstructorInfo>, IEnumerable<ConstructorInfo>> selectionRule) { ContainerConfiguration.ConstructorSelectionRule = selectionRule; return this; } public ContainerConfigurator OnContainerConfigurationChanged(Action<ContainerConfiguration> configurationChanged) { ContainerConfiguration.ConfigurationChangedEvent = configurationChanged; return this; } public ContainerConfigurator TreatParameterAndMemberNameAsDependencyName(bool enabled = true) { ContainerConfiguration.TreatingParameterAndMemberNameAsDependencyNameEnabled = enabled; return this; } public ContainerConfigurator WithNamedDependencyResolutionForUnNamedRequests(bool enabled = true) { ContainerConfiguration.NamedDependencyResolutionForUnNamedRequestsEnabled = enabled; return this; } public ContainerConfigurator WithDefaultLifetime(LifetimeDescriptor lifetime) { ContainerConfiguration.DefaultLifetime = lifetime; return this; } public ContainerConfigurator WithLifetimeValidation(bool enabled = true) { ContainerConfiguration.LifetimeValidationEnabled = enabled; return this; } public ContainerConfigurator WithReBuildSingletonsInChildContainer(bool enabled = true) { ContainerConfiguration.ReBuildSingletonsInChildContainerEnabled = enabled; return this; } public ContainerConfigurator WithExpressionCompiler(Func<LambdaExpression, Delegate> compilerDelegate) { ContainerConfiguration.ExternalExpressionCompiler = compilerDelegate; return this; } } }