Table of Contents

Class ServiceDescriptor

Namespace
Microsoft.Extensions.DependencyInjection
Assembly
nanoFramework.DependencyInjection.dll

Describes a service with its service type, implementation, and lifetime.

public class ServiceDescriptor
Inheritance
ServiceDescriptor
Inherited Members
Extension Methods

Constructors

ServiceDescriptor(Type, ImplementationFactoryDelegate, ServiceLifetime)

Initializes a new instance of ServiceDescriptor with the specified implementationFactory.

public ServiceDescriptor(Type serviceType, ImplementationFactoryDelegate implementationFactory, ServiceLifetime lifetime)

Parameters

serviceType Type

The Type of the service.

implementationFactory ImplementationFactoryDelegate

A factory used for creating service instances.

lifetime ServiceLifetime

The ServiceLifetime of the service.

Exceptions

ArgumentNullException

serviceType can't be null

ArgumentNullException

implementationFactory can't be null

ArgumentException

Implementation type cannot be an abstract or interface class.

ServiceDescriptor(Type, object)

Initializes a new instance of ServiceDescriptor with the specified instance as a Singleton.

public ServiceDescriptor(Type serviceType, object instance)

Parameters

serviceType Type

The Type of the service.

instance object

The instance implementing the service.

Exceptions

ArgumentNullException

serviceType or instance can't be null

ServiceDescriptor(Type, Type, ServiceLifetime)

Initializes a new instance of ServiceDescriptor with the specified implementationType.

public ServiceDescriptor(Type serviceType, Type implementationType, ServiceLifetime lifetime)

Parameters

serviceType Type

The Type of the service.

implementationType Type

The Type implementing the service.

lifetime ServiceLifetime

The ServiceLifetime of the service.

Exceptions

ArgumentNullException

serviceType or implementationType can't be null

ArgumentException

Implementation type cannot be an abstract or interface class.

Properties

ImplementationFactory

Gets the factory used for creating service instances.

public ImplementationFactoryDelegate ImplementationFactory { get; set; }

Property Value

ImplementationFactoryDelegate

ImplementationInstance

The instance of the implementation.

public object ImplementationInstance { get; set; }

Property Value

object

ImplementationType

The Type implementing the service.

public Type ImplementationType { get; }

Property Value

Type

Lifetime

The ServiceLifetime of the service.

public ServiceLifetime Lifetime { get; }

Property Value

ServiceLifetime

ServiceType

The Type of the service.

public Type ServiceType { get; }

Property Value

Type

Methods

Describe(Type, Type, ServiceLifetime)

Creates an instance of ServiceDescriptor with the specified serviceType, implementationType, and lifetime.

public static ServiceDescriptor Describe(Type serviceType, Type implementationType, ServiceLifetime lifetime)

Parameters

serviceType Type

The type of the service.

implementationType Type

The type of the implementation.

lifetime ServiceLifetime

The lifetime of the service.

Returns

ServiceDescriptor

A new instance of ServiceDescriptor.

GetImplementationType()

Returns the Type implementing the instance.

public Type GetImplementationType()

Returns

Type

ToString()

Returns a string that represents the current object.

public override string ToString()

Returns

string