Microsoft.Extensions.DependencyInjection.Abstractions by Microsoft

<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="5.0.0-preview.4.20251.6" />

 ServiceDescriptor

public class ServiceDescriptor
Describes a service with its service type, implementation, and lifetime.
public Func<IServiceProvider, object> ImplementationFactory { get; }

public object ImplementationInstance { get; }

public Type ImplementationType { get; }

public ServiceLifetime Lifetime { get; }

public Type ServiceType { get; }

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

Initializes a new instance of ServiceDescriptor with the specified implementationType.

public ServiceDescriptor(Type serviceType, object instance)

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

public ServiceDescriptor(Type serviceType, Func<IServiceProvider, object> factory, ServiceLifetime lifetime)

Initializes a new instance of ServiceDescriptor with the specified factory.

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

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

public static ServiceDescriptor Describe(Type serviceType, Func<IServiceProvider, object> implementationFactory, ServiceLifetime lifetime)

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

public static ServiceDescriptor Scoped<TService, TImplementation>() where TImplementation : TService

Creates an instance of ServiceDescriptor with the specified TService, TImplementation, and the Scoped lifetime.

public static ServiceDescriptor Scoped(Type service, Type implementationType)

Creates an instance of ServiceDescriptor with the specified service and implementationType and the Scoped lifetime.

public static ServiceDescriptor Scoped<TService, TImplementation>(Func<IServiceProvider, TImplementation> implementationFactory) where TImplementation : TService

Creates an instance of ServiceDescriptor with the specified TService, TImplementation, implementationFactory, and the Scoped lifetime.

public static ServiceDescriptor Scoped<TService>(Func<IServiceProvider, TService> implementationFactory)

Creates an instance of ServiceDescriptor with the specified TService, implementationFactory, and the Scoped lifetime.

public static ServiceDescriptor Scoped(Type service, Func<IServiceProvider, object> implementationFactory)

Creates an instance of ServiceDescriptor with the specified service, implementationFactory, and the Scoped lifetime.

public static ServiceDescriptor Singleton<TService, TImplementation>() where TImplementation : TService

Creates an instance of ServiceDescriptor with the specified TService, TImplementation, and the Singleton lifetime.

public static ServiceDescriptor Singleton(Type service, Type implementationType)

Creates an instance of ServiceDescriptor with the specified service and implementationType and the Singleton lifetime.

public static ServiceDescriptor Singleton<TService, TImplementation>(Func<IServiceProvider, TImplementation> implementationFactory) where TImplementation : TService

Creates an instance of ServiceDescriptor with the specified TService, TImplementation, implementationFactory, and the Singleton lifetime.

public static ServiceDescriptor Singleton<TService>(Func<IServiceProvider, TService> implementationFactory)

Creates an instance of ServiceDescriptor with the specified TService, implementationFactory, and the Singleton lifetime.

public static ServiceDescriptor Singleton(Type serviceType, Func<IServiceProvider, object> implementationFactory)

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

public static ServiceDescriptor Singleton<TService>(TService implementationInstance)

Creates an instance of ServiceDescriptor with the specified TService, implementationInstance, and the Singleton lifetime.

public static ServiceDescriptor Singleton(Type serviceType, object implementationInstance)

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

public static ServiceDescriptor Transient<TService, TImplementation>() where TImplementation : TService

Creates an instance of ServiceDescriptor with the specified TService, TImplementation, and the Transient lifetime.

public static ServiceDescriptor Transient(Type service, Type implementationType)

Creates an instance of ServiceDescriptor with the specified service and implementationType and the Transient lifetime.

public static ServiceDescriptor Transient<TService, TImplementation>(Func<IServiceProvider, TImplementation> implementationFactory) where TImplementation : TService

Creates an instance of ServiceDescriptor with the specified TService, TImplementation, implementationFactory, and the Transient lifetime.

public static ServiceDescriptor Transient<TService>(Func<IServiceProvider, TService> implementationFactory)

Creates an instance of ServiceDescriptor with the specified TService, implementationFactory, and the Transient lifetime.

public static ServiceDescriptor Transient(Type service, Func<IServiceProvider, object> implementationFactory)

Creates an instance of ServiceDescriptor with the specified service, implementationFactory, and the Transient lifetime.