ServiceDescriptor.Transient 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
多載
| 名稱 | Description |
|---|---|
| Transient(Type, Func<IServiceProvider,Object>) |
建立一個具有指定 、 |
| Transient(Type, Type) |
建立一個帶有指定 和 的實例ServiceDescriptor,且 壽命為 Transient 。 |
| Transient<TService,TImplementation>() |
建立一個具有指定 、 |
| Transient<TService,TImplementation>(Func<IServiceProvider,TImplementation>) |
建立一個具有指定 、 、 |
| Transient<TService>(Func<IServiceProvider,TService>) |
建立一個具有指定 、 |
Transient(Type, Func<IServiceProvider,Object>)
建立一個具有指定 、 implementationFactory、 及壽命的Transient實例ServiceDescriptor。service
public:
static Microsoft::Extensions::DependencyInjection::ServiceDescriptor ^ Transient(Type ^ service, Func<IServiceProvider ^, System::Object ^> ^ implementationFactory);
public static Microsoft.Extensions.DependencyInjection.ServiceDescriptor Transient(Type service, Func<IServiceProvider,object> implementationFactory);
static member Transient : Type * Func<IServiceProvider, obj> -> Microsoft.Extensions.DependencyInjection.ServiceDescriptor
Public Shared Function Transient (service As Type, implementationFactory As Func(Of IServiceProvider, Object)) As ServiceDescriptor
參數
- service
- Type
服務的類型。
- implementationFactory
- Func<IServiceProvider,Object>
一個工廠,用來建立服務實作的新實例。
傳回
一個新的實例。ServiceDescriptor
適用於
Transient(Type, Type)
建立一個帶有指定 和 的實例ServiceDescriptor,且 壽命為 Transient 。implementationTypeservice
public:
static Microsoft::Extensions::DependencyInjection::ServiceDescriptor ^ Transient(Type ^ service, Type ^ implementationType);
public static Microsoft.Extensions.DependencyInjection.ServiceDescriptor Transient(Type service, Type implementationType);
static member Transient : Type * Type -> Microsoft.Extensions.DependencyInjection.ServiceDescriptor
Public Shared Function Transient (service As Type, implementationType As Type) As ServiceDescriptor
參數
- service
- Type
服務的類型。
- implementationType
- Type
實作的類型。
傳回
一個新的實例。ServiceDescriptor
適用於
Transient<TService,TImplementation>()
建立一個具有指定 、 TImplementation、 及壽命的Transient實例ServiceDescriptor。TService
public:
generic <typename TService, typename TImplementation>
where TService : class where TImplementation : class, TService static Microsoft::Extensions::DependencyInjection::ServiceDescriptor ^ Transient();
public static Microsoft.Extensions.DependencyInjection.ServiceDescriptor Transient<TService,TImplementation>() where TService : class where TImplementation : class, TService;
static member Transient : unit -> Microsoft.Extensions.DependencyInjection.ServiceDescriptor (requires 'Service : null)
Public Shared Function Transient(Of TService As Class, TImplementation As Class) () As ServiceDescriptor
類型參數
- TService
服務的類型。
- TImplementation
實作的類型。
傳回
一個新的實例。ServiceDescriptor
適用於
Transient<TService,TImplementation>(Func<IServiceProvider,TImplementation>)
建立一個具有指定 、 、 implementationFactory、 及Transient壽命的實例ServiceDescriptor。 TImplementationTService
public:
generic <typename TService, typename TImplementation>
where TService : class where TImplementation : class, TService static Microsoft::Extensions::DependencyInjection::ServiceDescriptor ^ Transient(Func<IServiceProvider ^, TImplementation> ^ implementationFactory);
public static Microsoft.Extensions.DependencyInjection.ServiceDescriptor Transient<TService,TImplementation>(Func<IServiceProvider,TImplementation> implementationFactory) where TService : class where TImplementation : class, TService;
static member Transient : Func<IServiceProvider, #'Service> -> Microsoft.Extensions.DependencyInjection.ServiceDescriptor (requires 'Service : null)
Public Shared Function Transient(Of TService As Class, TImplementation As Class) (implementationFactory As Func(Of IServiceProvider, TImplementation)) As ServiceDescriptor
類型參數
- TService
服務的類型。
- TImplementation
實作的類型。
參數
- implementationFactory
- Func<IServiceProvider,TImplementation>
一個工廠,用來建立服務實作的新實例。
傳回
一個新的實例。ServiceDescriptor
適用於
Transient<TService>(Func<IServiceProvider,TService>)
建立一個具有指定 、 implementationFactory、 及壽命的Transient實例ServiceDescriptor。TService
public:
generic <typename TService>
where TService : class static Microsoft::Extensions::DependencyInjection::ServiceDescriptor ^ Transient(Func<IServiceProvider ^, TService> ^ implementationFactory);
public static Microsoft.Extensions.DependencyInjection.ServiceDescriptor Transient<TService>(Func<IServiceProvider,TService> implementationFactory) where TService : class;
static member Transient : Func<IServiceProvider, 'Service (requires 'Service : null)> -> Microsoft.Extensions.DependencyInjection.ServiceDescriptor (requires 'Service : null)
Public Shared Function Transient(Of TService As Class) (implementationFactory As Func(Of IServiceProvider, TService)) As ServiceDescriptor
類型參數
- TService
服務的類型。
參數
- implementationFactory
- Func<IServiceProvider,TService>
一個工廠,用來建立服務實作的新實例。
傳回
一個新的實例。ServiceDescriptor