Table of Contents

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

IReadOnlyList<Assembly>

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

bool

Lifetime

Lifetime for every scanned handler, processor and exception handler. Default: Transient.

public ServiceLifetime Lifetime { get; set; }

Property Value

ServiceLifetime

MediatorImplementationType

The IMediator implementation to register. Default: Mediator.

public Type MediatorImplementationType { get; set; }

Property Value

Type

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

ServiceLifetime

NotificationPublisher

A ready-made publisher instance. Takes precedence over NotificationPublisherType when set.

public INotificationPublisher? NotificationPublisher { get; set; }

Property Value

INotificationPublisher

NotificationPublisherType

The publisher type to register. Default: ForeachAwaitPublisher.

public Type NotificationPublisherType { get; set; }

Property Value

Type

RequestExceptionActionProcessorStrategy

Where exception actions sit in the pipeline. Default: ApplyForUnhandledExceptions.

public RequestExceptionActionProcessorStrategy RequestExceptionActionProcessorStrategy { get; set; }

Property Value

RequestExceptionActionProcessorStrategy

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

Func<Type, bool>

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

implementationType Type
lifetime ServiceLifetime

Returns

CaesarServiceConfiguration

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

serviceType Type
implementationType Type
lifetime ServiceLifetime

Returns

CaesarServiceConfiguration

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

lifetime ServiceLifetime

Returns

CaesarServiceConfiguration

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

lifetime ServiceLifetime

Returns

CaesarServiceConfiguration

Type Parameters

TService
TImplementation

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

openBehaviorType Type
lifetime ServiceLifetime

Returns

CaesarServiceConfiguration

AddOpenBehaviors(IEnumerable<Type>, ServiceLifetime)

Adds several open-generic behaviors.

public CaesarServiceConfiguration AddOpenBehaviors(IEnumerable<Type> openBehaviorTypes, ServiceLifetime lifetime = ServiceLifetime.Transient)

Parameters

openBehaviorTypes IEnumerable<Type>
lifetime ServiceLifetime

Returns

CaesarServiceConfiguration

AddOpenRequestPostProcessor(Type, ServiceLifetime)

Adds an open-generic post-processor that applies to every request.

public CaesarServiceConfiguration AddOpenRequestPostProcessor(Type openProcessorType, ServiceLifetime lifetime = ServiceLifetime.Transient)

Parameters

openProcessorType Type
lifetime ServiceLifetime

Returns

CaesarServiceConfiguration

AddOpenRequestPreProcessor(Type, ServiceLifetime)

Adds an open-generic pre-processor that applies to every request.

public CaesarServiceConfiguration AddOpenRequestPreProcessor(Type openProcessorType, ServiceLifetime lifetime = ServiceLifetime.Transient)

Parameters

openProcessorType Type
lifetime ServiceLifetime

Returns

CaesarServiceConfiguration

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

openBehaviorType Type
lifetime ServiceLifetime

Returns

CaesarServiceConfiguration

AddRequestPostProcessor(Type, ServiceLifetime)

Adds a closed post-processor.

public CaesarServiceConfiguration AddRequestPostProcessor(Type implementationType, ServiceLifetime lifetime = ServiceLifetime.Transient)

Parameters

implementationType Type
lifetime ServiceLifetime

Returns

CaesarServiceConfiguration

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

serviceType Type
implementationType Type
lifetime ServiceLifetime

Returns

CaesarServiceConfiguration

AddRequestPostProcessor<TImplementation>(ServiceLifetime)

Adds a closed post-processor.

public CaesarServiceConfiguration AddRequestPostProcessor<TImplementation>(ServiceLifetime lifetime = ServiceLifetime.Transient) where TImplementation : class

Parameters

lifetime ServiceLifetime

Returns

CaesarServiceConfiguration

Type Parameters

TImplementation

AddRequestPreProcessor(Type, ServiceLifetime)

Adds a closed pre-processor.

public CaesarServiceConfiguration AddRequestPreProcessor(Type implementationType, ServiceLifetime lifetime = ServiceLifetime.Transient)

Parameters

implementationType Type
lifetime ServiceLifetime

Returns

CaesarServiceConfiguration

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

serviceType Type
implementationType Type
lifetime ServiceLifetime

Returns

CaesarServiceConfiguration

AddRequestPreProcessor<TImplementation>(ServiceLifetime)

Adds a closed pre-processor.

public CaesarServiceConfiguration AddRequestPreProcessor<TImplementation>(ServiceLifetime lifetime = ServiceLifetime.Transient) where TImplementation : class

Parameters

lifetime ServiceLifetime

Returns

CaesarServiceConfiguration

Type Parameters

TImplementation

AddStreamBehavior(Type, ServiceLifetime)

Adds a closed stream behavior.

public CaesarServiceConfiguration AddStreamBehavior(Type implementationType, ServiceLifetime lifetime = ServiceLifetime.Transient)

Parameters

implementationType Type
lifetime ServiceLifetime

Returns

CaesarServiceConfiguration

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

serviceType Type
implementationType Type
lifetime ServiceLifetime

Returns

CaesarServiceConfiguration

AddStreamBehavior<TImplementation>(ServiceLifetime)

Adds a closed stream behavior.

public CaesarServiceConfiguration AddStreamBehavior<TImplementation>(ServiceLifetime lifetime = ServiceLifetime.Transient) where TImplementation : class

Parameters

lifetime ServiceLifetime

Returns

CaesarServiceConfiguration

Type Parameters

TImplementation

RegisterServicesFromAssemblies(params IEnumerable<Assembly>)

Adds several assemblies to the scan list.

public CaesarServiceConfiguration RegisterServicesFromAssemblies(params IEnumerable<Assembly> assemblies)

Parameters

assemblies IEnumerable<Assembly>

Returns

CaesarServiceConfiguration

RegisterServicesFromAssembly(Assembly)

Adds assembly to the scan list.

public CaesarServiceConfiguration RegisterServicesFromAssembly(Assembly assembly)

Parameters

assembly Assembly

Returns

CaesarServiceConfiguration

RegisterServicesFromAssemblyContaining(Type)

Adds the assembly that contains type to the scan list.

public CaesarServiceConfiguration RegisterServicesFromAssemblyContaining(Type type)

Parameters

type Type

Returns

CaesarServiceConfiguration

RegisterServicesFromAssemblyContaining<T>()

Adds the assembly that contains T to the scan list.

public CaesarServiceConfiguration RegisterServicesFromAssemblyContaining<T>()

Returns

CaesarServiceConfiguration

Type Parameters

T