Skip to content

ServiceRegistrationAttribute Class

Definition

Attribute used to define the service registration of a given type

C#
[AttributeUsage(AttributeTargets.Class, AllowMultiple = true)]
public class ServiceRegistrationAttribute : Attribute

Inheritance objectAttribute

Remarks

Constructor to specify the service type including optional runtime

Constructors

ServiceRegistrationAttribute(ServiceLifetime, params Type[])

Attribute used to define the service registration of a given type

C#
public ServiceRegistrationAttribute(ServiceLifetime lifetime, params Type[] serviceTypes)

Parameters

lifetime ServiceLifetime

serviceTypes Type[]

Remarks

Constructor to specify the service type including optional runtime

ServiceRegistrationAttribute(params Type[])

Constructor to specify the service type including optional runtime

C#
public ServiceRegistrationAttribute(params Type[] serviceTypes)

Parameters

serviceTypes Type[]

Remarks

The default lifetime is Singleton

Properties

ServiceTypes

The service type

C#
public ImmutableArray<Type> ServiceTypes { get; }

Lifetime

The lifetime

C#
public ServiceLifetime Lifetime { get; }