Class CaesarServiceConfiguration
- Namespace
- Caesar.DependencyInjection
- Assembly
- Caesar.dll
Options for AddCaesar: which assemblies to scan, which behaviors to add, and how services are registered.
public sealed class CaesarServiceConfiguration
- Inheritance
-
CaesarServiceConfiguration
- Inherited Members
Constructors
CaesarServiceConfiguration()
public CaesarServiceConfiguration()
Properties
AssembliesToRegister
Assemblies that will be scanned for handlers.
public IReadOnlyList<Assembly> AssembliesToRegister { get; }
Property Value
AutoRegisterRequestProcessors
When true (default) scanned IRequestPreProcessor<TRequest> and
IRequestPostProcessor<TRequest, TResponse> implementations are registered automatically.
Set to false to register processors only explicitly via AddRequestPreProcessor / AddRequestPostProcessor.
public bool AutoRegisterRequestProcessors { get; set; }
Property Value
Lifetime
Lifetime for every scanned handler, processor and exception handler. Default: Transient.
public ServiceLifetime Lifetime { get; set; }
Property Value
MediatorImplementationType
public Type MediatorImplementationType { get; set; }
Property Value
MediatorLifetime
Lifetime for IMediator, ISender, IPublisher and INotificationPublisher. Default: Scoped, so that a singleton capturing the mediator is reported by container validation at startup instead of failing on the first request. Set to Transient or Singleton when the mediator must be resolvable straight from the root provider, for example in a console application.
public ServiceLifetime MediatorLifetime { get; set; }
Property Value
NotificationPublisher
A ready-made publisher instance. Takes precedence over NotificationPublisherType when set.
public INotificationPublisher? NotificationPublisher { get; set; }
Property Value
NotificationPublisherType
The publisher type to register. Default: ForeachAwaitPublisher.
public Type NotificationPublisherType { get; set; }
Property Value
RequestExceptionActionProcessorStrategy
Where exception actions sit in the pipeline. Default: ApplyForUnhandledExceptions.
public RequestExceptionActionProcessorStrategy RequestExceptionActionProcessorStrategy { get; set; }
Property Value
TypeEvaluator
Filters the types found while scanning. Return false to skip a type. Default: accept everything.
public Func<Type, bool> TypeEvaluator { get; set; }
Property Value
Methods
AddBehavior(Type, ServiceLifetime)
Adds a closed behavior. The service type is every IPipelineBehavior<TRequest, TResponse> it implements.
public CaesarServiceConfiguration AddBehavior(Type implementationType, ServiceLifetime lifetime = ServiceLifetime.Transient)
Parameters
implementationTypeTypelifetimeServiceLifetime
Returns
AddBehavior(Type, Type, ServiceLifetime)
Adds a closed behavior for one specific service type.
public CaesarServiceConfiguration AddBehavior(Type serviceType, Type implementationType, ServiceLifetime lifetime = ServiceLifetime.Transient)
Parameters
serviceTypeTypeimplementationTypeTypelifetimeServiceLifetime
Returns
AddBehavior<TImplementation>(ServiceLifetime)
Adds a closed behavior. The service type is every IPipelineBehavior<TRequest, TResponse> it implements.
public CaesarServiceConfiguration AddBehavior<TImplementation>(ServiceLifetime lifetime = ServiceLifetime.Transient) where TImplementation : class
Parameters
lifetimeServiceLifetime
Returns
Type Parameters
TImplementation
AddBehavior<TService, TImplementation>(ServiceLifetime)
Adds a closed behavior for one specific service type.
public CaesarServiceConfiguration AddBehavior<TService, TImplementation>(ServiceLifetime lifetime = ServiceLifetime.Transient) where TService : class where TImplementation : class, TService
Parameters
lifetimeServiceLifetime
Returns
Type Parameters
TServiceTImplementation
AddOpenBehavior(Type, ServiceLifetime)
Adds an open-generic behavior such as typeof(LoggingBehavior<,>) that applies to every request.
The type must implement IPipelineBehavior<TRequest, TResponse> with its own two type parameters.
public CaesarServiceConfiguration AddOpenBehavior(Type openBehaviorType, ServiceLifetime lifetime = ServiceLifetime.Transient)
Parameters
openBehaviorTypeTypelifetimeServiceLifetime
Returns
AddOpenBehaviors(IEnumerable<Type>, ServiceLifetime)
Adds several open-generic behaviors.
public CaesarServiceConfiguration AddOpenBehaviors(IEnumerable<Type> openBehaviorTypes, ServiceLifetime lifetime = ServiceLifetime.Transient)
Parameters
openBehaviorTypesIEnumerable<Type>lifetimeServiceLifetime
Returns
AddOpenRequestPostProcessor(Type, ServiceLifetime)
Adds an open-generic post-processor that applies to every request.
public CaesarServiceConfiguration AddOpenRequestPostProcessor(Type openProcessorType, ServiceLifetime lifetime = ServiceLifetime.Transient)
Parameters
openProcessorTypeTypelifetimeServiceLifetime
Returns
AddOpenRequestPreProcessor(Type, ServiceLifetime)
Adds an open-generic pre-processor that applies to every request.
public CaesarServiceConfiguration AddOpenRequestPreProcessor(Type openProcessorType, ServiceLifetime lifetime = ServiceLifetime.Transient)
Parameters
openProcessorTypeTypelifetimeServiceLifetime
Returns
AddOpenStreamBehavior(Type, ServiceLifetime)
Adds an open-generic stream behavior that applies to every stream request.
public CaesarServiceConfiguration AddOpenStreamBehavior(Type openBehaviorType, ServiceLifetime lifetime = ServiceLifetime.Transient)
Parameters
openBehaviorTypeTypelifetimeServiceLifetime
Returns
AddRequestPostProcessor(Type, ServiceLifetime)
Adds a closed post-processor.
public CaesarServiceConfiguration AddRequestPostProcessor(Type implementationType, ServiceLifetime lifetime = ServiceLifetime.Transient)
Parameters
implementationTypeTypelifetimeServiceLifetime
Returns
AddRequestPostProcessor(Type, Type, ServiceLifetime)
Adds a closed post-processor for one specific service type.
public CaesarServiceConfiguration AddRequestPostProcessor(Type serviceType, Type implementationType, ServiceLifetime lifetime = ServiceLifetime.Transient)
Parameters
serviceTypeTypeimplementationTypeTypelifetimeServiceLifetime
Returns
AddRequestPostProcessor<TImplementation>(ServiceLifetime)
Adds a closed post-processor.
public CaesarServiceConfiguration AddRequestPostProcessor<TImplementation>(ServiceLifetime lifetime = ServiceLifetime.Transient) where TImplementation : class
Parameters
lifetimeServiceLifetime
Returns
Type Parameters
TImplementation
AddRequestPreProcessor(Type, ServiceLifetime)
Adds a closed pre-processor.
public CaesarServiceConfiguration AddRequestPreProcessor(Type implementationType, ServiceLifetime lifetime = ServiceLifetime.Transient)
Parameters
implementationTypeTypelifetimeServiceLifetime
Returns
AddRequestPreProcessor(Type, Type, ServiceLifetime)
Adds a closed pre-processor for one specific service type.
public CaesarServiceConfiguration AddRequestPreProcessor(Type serviceType, Type implementationType, ServiceLifetime lifetime = ServiceLifetime.Transient)
Parameters
serviceTypeTypeimplementationTypeTypelifetimeServiceLifetime
Returns
AddRequestPreProcessor<TImplementation>(ServiceLifetime)
Adds a closed pre-processor.
public CaesarServiceConfiguration AddRequestPreProcessor<TImplementation>(ServiceLifetime lifetime = ServiceLifetime.Transient) where TImplementation : class
Parameters
lifetimeServiceLifetime
Returns
Type Parameters
TImplementation
AddStreamBehavior(Type, ServiceLifetime)
Adds a closed stream behavior.
public CaesarServiceConfiguration AddStreamBehavior(Type implementationType, ServiceLifetime lifetime = ServiceLifetime.Transient)
Parameters
implementationTypeTypelifetimeServiceLifetime
Returns
AddStreamBehavior(Type, Type, ServiceLifetime)
Adds a closed stream behavior for one specific service type.
public CaesarServiceConfiguration AddStreamBehavior(Type serviceType, Type implementationType, ServiceLifetime lifetime = ServiceLifetime.Transient)
Parameters
serviceTypeTypeimplementationTypeTypelifetimeServiceLifetime
Returns
AddStreamBehavior<TImplementation>(ServiceLifetime)
Adds a closed stream behavior.
public CaesarServiceConfiguration AddStreamBehavior<TImplementation>(ServiceLifetime lifetime = ServiceLifetime.Transient) where TImplementation : class
Parameters
lifetimeServiceLifetime
Returns
Type Parameters
TImplementation
RegisterServicesFromAssemblies(params IEnumerable<Assembly>)
Adds several assemblies to the scan list.
public CaesarServiceConfiguration RegisterServicesFromAssemblies(params IEnumerable<Assembly> assemblies)
Parameters
assembliesIEnumerable<Assembly>
Returns
RegisterServicesFromAssembly(Assembly)
Adds assembly to the scan list.
public CaesarServiceConfiguration RegisterServicesFromAssembly(Assembly assembly)
Parameters
assemblyAssembly
Returns
RegisterServicesFromAssemblyContaining(Type)
Adds the assembly that contains type to the scan list.
public CaesarServiceConfiguration RegisterServicesFromAssemblyContaining(Type type)
Parameters
typeType
Returns
RegisterServicesFromAssemblyContaining<T>()
Adds the assembly that contains T to the scan list.
public CaesarServiceConfiguration RegisterServicesFromAssemblyContaining<T>()
Returns
Type Parameters
T