ServiceDescriptor.Singleton 方法

定义

重载

Singleton(Type, Func<IServiceProvider,Object>)

创建具有指定 serviceTypeimplementationFactorySingleton 生存期的 ServiceDescriptor 实例。

Singleton(Type, Object)

创建具有指定 serviceTypeimplementationInstanceScoped 生存期的 ServiceDescriptor 实例。

Singleton(Type, Type)

创建具有指定 serviceimplementationTypeSingleton 生存期的 ServiceDescriptor 实例。

Singleton<TService,TImplementation>()

创建具有指定 TServiceTImplementationSingleton 生存期的 ServiceDescriptor 实例。

Singleton<TService,TImplementation>(Func<IServiceProvider,TImplementation>)

创建具有指定 TServiceTImplementationimplementationFactorySingleton 生存期的 ServiceDescriptor 实例。

Singleton<TService>(Func<IServiceProvider,TService>)

创建具有指定 TServiceimplementationFactorySingleton 生存期的 ServiceDescriptor 实例。

Singleton<TService>(TService)

创建具有指定 TServiceimplementationInstanceScoped 生存期的 ServiceDescriptor 实例。

Singleton(Type, Func<IServiceProvider,Object>)

Source:
ServiceDescriptor.cs
Source:
ServiceDescriptor.cs
Source:
ServiceDescriptor.cs
Source:
ServiceDescriptor.cs
Source:
ServiceDescriptor.cs

创建具有指定 serviceTypeimplementationFactorySingleton 生存期的 ServiceDescriptor 实例。

public:
 static Microsoft::Extensions::DependencyInjection::ServiceDescriptor ^ Singleton(Type ^ serviceType, Func<IServiceProvider ^, System::Object ^> ^ implementationFactory);
public static Microsoft.Extensions.DependencyInjection.ServiceDescriptor Singleton (Type serviceType, Func<IServiceProvider,object> implementationFactory);
static member Singleton : Type * Func<IServiceProvider, obj> -> Microsoft.Extensions.DependencyInjection.ServiceDescriptor
Public Shared Function Singleton (serviceType As Type, implementationFactory As Func(Of IServiceProvider, Object)) As ServiceDescriptor

参数

serviceType
Type

服务的类型。

implementationFactory
Func<IServiceProvider,Object>

用于创建服务实现的新实例的工厂。

返回

ServiceDescriptor 的新实例。

适用于

Singleton(Type, Object)

Source:
ServiceDescriptor.cs
Source:
ServiceDescriptor.cs
Source:
ServiceDescriptor.cs
Source:
ServiceDescriptor.cs
Source:
ServiceDescriptor.cs

创建具有指定 serviceTypeimplementationInstanceScoped 生存期的 ServiceDescriptor 实例。

public:
 static Microsoft::Extensions::DependencyInjection::ServiceDescriptor ^ Singleton(Type ^ serviceType, System::Object ^ implementationInstance);
public static Microsoft.Extensions.DependencyInjection.ServiceDescriptor Singleton (Type serviceType, object implementationInstance);
static member Singleton : Type * obj -> Microsoft.Extensions.DependencyInjection.ServiceDescriptor
Public Shared Function Singleton (serviceType As Type, implementationInstance As Object) As ServiceDescriptor

参数

serviceType
Type

服务的类型。

implementationInstance
Object

实现的实例。

返回

ServiceDescriptor 的新实例。

适用于

Singleton(Type, Type)

Source:
ServiceDescriptor.cs
Source:
ServiceDescriptor.cs
Source:
ServiceDescriptor.cs
Source:
ServiceDescriptor.cs
Source:
ServiceDescriptor.cs

创建具有指定 serviceimplementationTypeSingleton 生存期的 ServiceDescriptor 实例。

public:
 static Microsoft::Extensions::DependencyInjection::ServiceDescriptor ^ Singleton(Type ^ service, Type ^ implementationType);
public static Microsoft.Extensions.DependencyInjection.ServiceDescriptor Singleton (Type service, Type implementationType);
static member Singleton : Type * Type -> Microsoft.Extensions.DependencyInjection.ServiceDescriptor
Public Shared Function Singleton (service As Type, implementationType As Type) As ServiceDescriptor

参数

service
Type

服务的类型。

implementationType
Type

实现的类型。

返回

ServiceDescriptor 的新实例。

适用于

Singleton<TService,TImplementation>()

Source:
ServiceDescriptor.cs
Source:
ServiceDescriptor.cs
Source:
ServiceDescriptor.cs
Source:
ServiceDescriptor.cs
Source:
ServiceDescriptor.cs

创建具有指定 TServiceTImplementationSingleton 生存期的 ServiceDescriptor 实例。

public:
generic <typename TService, typename TImplementation>
 where TService : class where TImplementation : class, TService static Microsoft::Extensions::DependencyInjection::ServiceDescriptor ^ Singleton();
public static Microsoft.Extensions.DependencyInjection.ServiceDescriptor Singleton<TService,TImplementation> () where TService : class where TImplementation : class, TService;
static member Singleton : unit -> Microsoft.Extensions.DependencyInjection.ServiceDescriptor (requires 'Service : null)
Public Shared Function Singleton(Of TService As Class, TImplementation As Class) () As ServiceDescriptor

类型参数

TService

服务的类型。

TImplementation

实现的类型。

返回

ServiceDescriptor 的新实例。

适用于

Singleton<TService,TImplementation>(Func<IServiceProvider,TImplementation>)

Source:
ServiceDescriptor.cs
Source:
ServiceDescriptor.cs
Source:
ServiceDescriptor.cs
Source:
ServiceDescriptor.cs
Source:
ServiceDescriptor.cs

创建具有指定 TServiceTImplementationimplementationFactorySingleton 生存期的 ServiceDescriptor 实例。

public:
generic <typename TService, typename TImplementation>
 where TService : class where TImplementation : class, TService static Microsoft::Extensions::DependencyInjection::ServiceDescriptor ^ Singleton(Func<IServiceProvider ^, TImplementation> ^ implementationFactory);
public static Microsoft.Extensions.DependencyInjection.ServiceDescriptor Singleton<TService,TImplementation> (Func<IServiceProvider,TImplementation> implementationFactory) where TService : class where TImplementation : class, TService;
static member Singleton : Func<IServiceProvider, #'Service> -> Microsoft.Extensions.DependencyInjection.ServiceDescriptor (requires 'Service : null)
Public Shared Function Singleton(Of TService As Class, TImplementation As Class) (implementationFactory As Func(Of IServiceProvider, TImplementation)) As ServiceDescriptor

类型参数

TService

服务的类型。

TImplementation

实现的类型。

参数

implementationFactory
Func<IServiceProvider,TImplementation>

用于创建服务实现的新实例的工厂。

返回

ServiceDescriptor 的新实例。

适用于

Singleton<TService>(Func<IServiceProvider,TService>)

Source:
ServiceDescriptor.cs
Source:
ServiceDescriptor.cs
Source:
ServiceDescriptor.cs
Source:
ServiceDescriptor.cs
Source:
ServiceDescriptor.cs

创建具有指定 TServiceimplementationFactorySingleton 生存期的 ServiceDescriptor 实例。

public:
generic <typename TService>
 where TService : class static Microsoft::Extensions::DependencyInjection::ServiceDescriptor ^ Singleton(Func<IServiceProvider ^, TService> ^ implementationFactory);
public static Microsoft.Extensions.DependencyInjection.ServiceDescriptor Singleton<TService> (Func<IServiceProvider,TService> implementationFactory) where TService : class;
static member Singleton : Func<IServiceProvider, 'Service (requires 'Service : null)> -> Microsoft.Extensions.DependencyInjection.ServiceDescriptor (requires 'Service : null)
Public Shared Function Singleton(Of TService As Class) (implementationFactory As Func(Of IServiceProvider, TService)) As ServiceDescriptor

类型参数

TService

服务的类型。

参数

implementationFactory
Func<IServiceProvider,TService>

用于创建服务实现的新实例的工厂。

返回

ServiceDescriptor 的新实例。

适用于

Singleton<TService>(TService)

Source:
ServiceDescriptor.cs
Source:
ServiceDescriptor.cs
Source:
ServiceDescriptor.cs
Source:
ServiceDescriptor.cs
Source:
ServiceDescriptor.cs

创建具有指定 TServiceimplementationInstanceScoped 生存期的 ServiceDescriptor 实例。

public:
generic <typename TService>
 where TService : class static Microsoft::Extensions::DependencyInjection::ServiceDescriptor ^ Singleton(TService implementationInstance);
public static Microsoft.Extensions.DependencyInjection.ServiceDescriptor Singleton<TService> (TService implementationInstance) where TService : class;
static member Singleton : 'Service -> Microsoft.Extensions.DependencyInjection.ServiceDescriptor (requires 'Service : null)
Public Shared Function Singleton(Of TService As Class) (implementationInstance As TService) As ServiceDescriptor

类型参数

TService

服务的类型。

参数

implementationInstance
TService

实现的实例。

返回

ServiceDescriptor 的新实例。

适用于