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
serviceTypeTypeThe Type of the service.
implementationFactoryImplementationFactoryDelegateA factory used for creating service instances.
lifetimeServiceLifetimeThe ServiceLifetime of the service.
Exceptions
- ArgumentNullException
serviceTypecan't be null- ArgumentNullException
implementationFactorycan'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
serviceTypeorinstancecan'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
serviceTypeTypeThe Type of the service.
implementationTypeTypeThe Type implementing the service.
lifetimeServiceLifetimeThe ServiceLifetime of the service.
Exceptions
- ArgumentNullException
serviceTypeorimplementationTypecan'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, ImplementationFactoryDelegate, ServiceLifetime)
Creates an instance of ServiceDescriptor with the specified
serviceType, implementationFactory,
and lifetime.
public static ServiceDescriptor Describe(Type serviceType, ImplementationFactoryDelegate implementationFactory, ServiceLifetime lifetime)
Parameters
serviceTypeTypeThe type of the service.
implementationFactoryImplementationFactoryDelegateA factory to create new instances of the service implementation.
lifetimeServiceLifetimeThe lifetime of the service.
Returns
- ServiceDescriptor
A new instance of ServiceDescriptor.
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
serviceTypeTypeThe type of the service.
implementationTypeTypeThe type of the implementation.
lifetimeServiceLifetimeThe lifetime of the service.
Returns
- ServiceDescriptor
A new instance of ServiceDescriptor.
GetImplementationType()
Returns the Type implementing the instance.
public Type GetImplementationType()
Returns
Scoped(Type, ImplementationFactoryDelegate)
Creates an instance of ServiceDescriptor with the specified
service and implementationFactory
and the Scoped lifetime.
public static ServiceDescriptor Scoped(Type service, ImplementationFactoryDelegate implementationFactory)
Parameters
serviceTypeThe type of the service.
implementationFactoryImplementationFactoryDelegateA factory to create new instances of the service implementation.
Returns
- ServiceDescriptor
A new instance of ServiceDescriptor.
Scoped(Type, Type)
Creates an instance of ServiceDescriptor with the specified
service and implementationType
and the Scoped lifetime.
public static ServiceDescriptor Scoped(Type service, Type implementationType)
Parameters
Returns
- ServiceDescriptor
A new instance of ServiceDescriptor.
Singleton(Type, ImplementationFactoryDelegate)
Creates an instance of ServiceDescriptor with the specified
service and implementationFactory
and the Singleton lifetime.
public static ServiceDescriptor Singleton(Type service, ImplementationFactoryDelegate implementationFactory)
Parameters
serviceTypeThe type of the service.
implementationFactoryImplementationFactoryDelegateA factory to create new instances of the service implementation.
Returns
- ServiceDescriptor
A new instance of ServiceDescriptor.
Singleton(Type, Type)
Creates an instance of ServiceDescriptor with the specified
service and implementationType
and the Singleton lifetime.
public static ServiceDescriptor Singleton(Type service, Type implementationType)
Parameters
Returns
- ServiceDescriptor
A new instance of ServiceDescriptor.
ToString()
Returns a string that represents the current object.
public override string ToString()
Returns
Transient(Type, ImplementationFactoryDelegate)
Creates an instance of ServiceDescriptor with the specified
service and implementationFactory
and the Transient lifetime.
public static ServiceDescriptor Transient(Type service, ImplementationFactoryDelegate implementationFactory)
Parameters
serviceTypeThe type of the service.
implementationFactoryImplementationFactoryDelegateA factory to create new instances of the service implementation.
Returns
- ServiceDescriptor
A new instance of ServiceDescriptor.
Transient(Type, Type)
Creates an instance of ServiceDescriptor with the specified
service and implementationType
and the Transient lifetime.
public static ServiceDescriptor Transient(Type service, Type implementationType)
Parameters
Returns
- ServiceDescriptor
A new instance of ServiceDescriptor.