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
TypeThe Type of the service.
implementationFactory
ImplementationFactoryDelegateA factory used for creating service instances.
lifetime
ServiceLifetimeThe 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
Exceptions
- ArgumentNullException
serviceType
orinstance
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
TypeThe Type of the service.
implementationType
TypeThe Type implementing the service.
lifetime
ServiceLifetimeThe ServiceLifetime of the service.
Exceptions
- ArgumentNullException
serviceType
orimplementationType
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
ImplementationInstance
The instance of the implementation.
public object ImplementationInstance { get; set; }
Property Value
ImplementationType
The Type implementing the service.
public Type ImplementationType { get; }
Property Value
Lifetime
The ServiceLifetime of the service.
public ServiceLifetime Lifetime { get; }
Property Value
ServiceType
The Type of the service.
public Type ServiceType { get; }
Property Value
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
TypeThe type of the service.
implementationType
TypeThe type of the implementation.
lifetime
ServiceLifetimeThe lifetime of the service.
Returns
- ServiceDescriptor
A new instance of ServiceDescriptor.
GetImplementationType()
Returns the Type implementing the instance.
public Type GetImplementationType()
Returns
ToString()
Returns a string that represents the current object.
public override string ToString()