FluentServiceConfigurator<TConfigurator>
public class FluentServiceConfigurator<TConfigurator> : BaseFluentConfigurator<TConfigurator> where TConfigurator : FluentServiceConfigurator<TConfigurator>
Represents the fluent service registration api.
using Stashbox.Lifetime;
using Stashbox.Utils;
using System;
using System.Collections.Generic;
using System.Runtime.CompilerServices;
namespace Stashbox.Registration.Fluent
{
[System.Runtime.CompilerServices.NullableContext(1)]
[System.Runtime.CompilerServices.Nullable(new byte[] {
0,
1
})]
public class FluentServiceConfigurator<[System.Runtime.CompilerServices.Nullable(0)] TConfigurator> : BaseFluentConfigurator<TConfigurator> where TConfigurator : FluentServiceConfigurator<TConfigurator>
{
internal FluentServiceConfigurator(Type serviceType, Type implementationType, [System.Runtime.CompilerServices.Nullable(2)] object name, LifetimeDescriptor lifetimeDescriptor, bool isDecorator)
: base(serviceType, implementationType, name, lifetimeDescriptor, isDecorator)
{
}
public TConfigurator WithDynamicResolution()
{
if (Options == null)
Options = new Dictionary<RegistrationOption, object>();
Options[RegistrationOption.IsResolutionCallRequired] = true;
return (TConfigurator)this;
}
public TConfigurator WithMetadata([System.Runtime.CompilerServices.Nullable(2)] object metadata)
{
if (Options == null)
Options = new Dictionary<RegistrationOption, object>();
Options[RegistrationOption.Metadata] = metadata;
return (TConfigurator)this;
}
public TConfigurator WithName([System.Runtime.CompilerServices.Nullable(2)] object name)
{
base.Name = name;
return (TConfigurator)this;
}
public TConfigurator DefinesScope([System.Runtime.CompilerServices.Nullable(2)] object scopeName = null)
{
if (Options == null)
Options = new Dictionary<RegistrationOption, object>();
Options[RegistrationOption.DefinedScopeName] = (scopeName ?? base.ImplementationType);
return (TConfigurator)this;
}
public TConfigurator WithFactory(Func<IDependencyResolver, object> factory, bool isCompiledLambda = false)
{
return SetFactory(factory, isCompiledLambda, Constants.ResolverType, Constants.ObjectType);
}
public TConfigurator WithFactory(Func<object> factory, bool isCompiledLambda = false)
{
return SetFactory(factory, isCompiledLambda, Constants.ObjectType);
}
public TConfigurator WithFactory<[System.Runtime.CompilerServices.Nullable(2)] T1>(Func<T1, object> factory, bool isCompiledLambda = false)
{
return base.SetFactory((Delegate)factory, isCompiledLambda, new Type[2] {
typeof(T1),
Constants.ObjectType
});
}
public TConfigurator WithFactory<[System.Runtime.CompilerServices.Nullable(2)] T1, [System.Runtime.CompilerServices.Nullable(2)] T2>(Func<T1, T2, object> factory, bool isCompiledLambda = false)
{
return base.SetFactory((Delegate)factory, isCompiledLambda, new Type[3] {
typeof(T1),
typeof(T2),
Constants.ObjectType
});
}
[System.Runtime.CompilerServices.NullableContext(2)]
[return: System.Runtime.CompilerServices.Nullable(1)]
public TConfigurator WithFactory<T1, T2, T3>([System.Runtime.CompilerServices.Nullable(1)] Func<T1, T2, T3, object> factory, bool isCompiledLambda = false)
{
return base.SetFactory((Delegate)factory, isCompiledLambda, new Type[4] {
typeof(T1),
typeof(T2),
typeof(T3),
Constants.ObjectType
});
}
[System.Runtime.CompilerServices.NullableContext(2)]
[return: System.Runtime.CompilerServices.Nullable(1)]
public TConfigurator WithFactory<T1, T2, T3, T4>([System.Runtime.CompilerServices.Nullable(1)] Func<T1, T2, T3, T4, object> factory, bool isCompiledLambda = false)
{
return base.SetFactory((Delegate)factory, isCompiledLambda, new Type[5] {
typeof(T1),
typeof(T2),
typeof(T3),
typeof(T4),
Constants.ObjectType
});
}
[System.Runtime.CompilerServices.NullableContext(2)]
[return: System.Runtime.CompilerServices.Nullable(1)]
public TConfigurator WithFactory<T1, T2, T3, T4, T5>([System.Runtime.CompilerServices.Nullable(1)] Func<T1, T2, T3, T4, T5, object> factory, bool isCompiledLambda = false)
{
return base.SetFactory((Delegate)factory, isCompiledLambda, new Type[6] {
typeof(T1),
typeof(T2),
typeof(T3),
typeof(T4),
typeof(T5),
Constants.ObjectType
});
}
}
}