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, TypeCache<IDependencyResolver>.Type, TypeCache<object>.Type);
}
public TConfigurator WithFactory(Func<object> factory, bool isCompiledLambda = false)
{
return SetFactory(factory, isCompiledLambda, TypeCache<object>.Type);
}
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] {
TypeCache<T1>.Type,
TypeCache<object>.Type
});
}
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] {
TypeCache<T1>.Type,
TypeCache<T2>.Type,
TypeCache<object>.Type
});
}
[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] {
TypeCache<T1>.Type,
TypeCache<T2>.Type,
TypeCache<T3>.Type,
TypeCache<object>.Type
});
}
[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] {
TypeCache<T1>.Type,
TypeCache<T2>.Type,
TypeCache<T3>.Type,
TypeCache<T4>.Type,
TypeCache<object>.Type
});
}
[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] {
TypeCache<T1>.Type,
TypeCache<T2>.Type,
TypeCache<T3>.Type,
TypeCache<T4>.Type,
TypeCache<T5>.Type,
TypeCache<object>.Type
});
}
}
}