Bagikan melalui


ServiceCollectionDescriptorExtensions.TryAddKeyedSingleton Metode

Definisi

Overload

TryAddKeyedSingleton(IServiceCollection, Type, Object)

Menambahkan yang ditentukan service sebagai Singleton layanan ke collection jika jenis layanan belum terdaftar.

TryAddKeyedSingleton(IServiceCollection, Type, Object, Func<IServiceProvider,Object,Object>)

Menambahkan yang ditentukan service sebagai Singleton layanan menggunakan pabrik yang ditentukan ke implementationFactorycollection jika jenis layanan belum terdaftar.

TryAddKeyedSingleton(IServiceCollection, Type, Object, Type)

Menambahkan yang ditentukan service sebagai Singleton layanan dengan implementationType implementasi ke collection jika jenis layanan belum terdaftar.

TryAddKeyedSingleton<TService,TImplementation>(IServiceCollection, Object)

Menambahkan yang ditentukan TService sebagai jenis implementasi layanan yang Singleton ditentukan dalam TImplementation jika collection jenis layanan belum terdaftar.

TryAddKeyedSingleton<TService>(IServiceCollection, Object)

Menambahkan yang ditentukan TService sebagai Singleton layanan ke collection jika jenis layanan belum terdaftar.

TryAddKeyedSingleton<TService>(IServiceCollection, Object, Func<IServiceProvider,Object,TService>)

Menambahkan yang ditentukan TService sebagai Singleton layanan menggunakan pabrik yang ditentukan ke implementationFactoryservices jika jenis layanan belum terdaftar.

TryAddKeyedSingleton<TService>(IServiceCollection, Object, TService)

Menambahkan yang ditentukan TService sebagai Singleton layanan dengan instans yang ditentukan ke instancecollection jika jenis layanan belum terdaftar.

TryAddKeyedSingleton(IServiceCollection, Type, Object)

Sumber:
ServiceCollectionDescriptorExtensions.Keyed.cs
Sumber:
ServiceCollectionDescriptorExtensions.Keyed.cs
Sumber:
ServiceCollectionDescriptorExtensions.Keyed.cs
Sumber:
ServiceCollectionDescriptorExtensions.Keyed.cs

Menambahkan yang ditentukan service sebagai Singleton layanan ke collection jika jenis layanan belum terdaftar.

public:
[System::Runtime::CompilerServices::Extension]
 static void TryAddKeyedSingleton(Microsoft::Extensions::DependencyInjection::IServiceCollection ^ collection, Type ^ service, System::Object ^ serviceKey);
public static void TryAddKeyedSingleton (this Microsoft.Extensions.DependencyInjection.IServiceCollection collection, Type service, object? serviceKey);
static member TryAddKeyedSingleton : Microsoft.Extensions.DependencyInjection.IServiceCollection * Type * obj -> unit
<Extension()>
Public Sub TryAddKeyedSingleton (collection As IServiceCollection, service As Type, serviceKey As Object)

Parameter

service
Type

Jenis layanan yang akan didaftarkan.

serviceKey
Object

Kunci layanan.

Berlaku untuk

TryAddKeyedSingleton(IServiceCollection, Type, Object, Func<IServiceProvider,Object,Object>)

Sumber:
ServiceCollectionDescriptorExtensions.Keyed.cs
Sumber:
ServiceCollectionDescriptorExtensions.Keyed.cs
Sumber:
ServiceCollectionDescriptorExtensions.Keyed.cs
Sumber:
ServiceCollectionDescriptorExtensions.Keyed.cs

Menambahkan yang ditentukan service sebagai Singleton layanan menggunakan pabrik yang ditentukan ke implementationFactorycollection jika jenis layanan belum terdaftar.

public:
[System::Runtime::CompilerServices::Extension]
 static void TryAddKeyedSingleton(Microsoft::Extensions::DependencyInjection::IServiceCollection ^ collection, Type ^ service, System::Object ^ serviceKey, Func<IServiceProvider ^, System::Object ^, System::Object ^> ^ implementationFactory);
public static void TryAddKeyedSingleton (this Microsoft.Extensions.DependencyInjection.IServiceCollection collection, Type service, object? serviceKey, Func<IServiceProvider,object?,object> implementationFactory);
static member TryAddKeyedSingleton : Microsoft.Extensions.DependencyInjection.IServiceCollection * Type * obj * Func<IServiceProvider, obj, obj> -> unit
<Extension()>
Public Sub TryAddKeyedSingleton (collection As IServiceCollection, service As Type, serviceKey As Object, implementationFactory As Func(Of IServiceProvider, Object, Object))

Parameter

service
Type

Jenis layanan yang akan didaftarkan.

serviceKey
Object

Kunci layanan.

implementationFactory
Func<IServiceProvider,Object,Object>

Pabrik yang membuat layanan.

Berlaku untuk

TryAddKeyedSingleton(IServiceCollection, Type, Object, Type)

Sumber:
ServiceCollectionDescriptorExtensions.Keyed.cs
Sumber:
ServiceCollectionDescriptorExtensions.Keyed.cs
Sumber:
ServiceCollectionDescriptorExtensions.Keyed.cs
Sumber:
ServiceCollectionDescriptorExtensions.Keyed.cs

Menambahkan yang ditentukan service sebagai Singleton layanan dengan implementationType implementasi ke collection jika jenis layanan belum terdaftar.

public:
[System::Runtime::CompilerServices::Extension]
 static void TryAddKeyedSingleton(Microsoft::Extensions::DependencyInjection::IServiceCollection ^ collection, Type ^ service, System::Object ^ serviceKey, Type ^ implementationType);
public static void TryAddKeyedSingleton (this Microsoft.Extensions.DependencyInjection.IServiceCollection collection, Type service, object? serviceKey, Type implementationType);
static member TryAddKeyedSingleton : Microsoft.Extensions.DependencyInjection.IServiceCollection * Type * obj * Type -> unit
<Extension()>
Public Sub TryAddKeyedSingleton (collection As IServiceCollection, service As Type, serviceKey As Object, implementationType As Type)

Parameter

service
Type

Jenis layanan yang akan didaftarkan.

serviceKey
Object

Kunci layanan.

implementationType
Type

Jenis implementasi layanan.

Berlaku untuk

TryAddKeyedSingleton<TService,TImplementation>(IServiceCollection, Object)

Sumber:
ServiceCollectionDescriptorExtensions.Keyed.cs
Sumber:
ServiceCollectionDescriptorExtensions.Keyed.cs
Sumber:
ServiceCollectionDescriptorExtensions.Keyed.cs
Sumber:
ServiceCollectionDescriptorExtensions.Keyed.cs

Menambahkan yang ditentukan TService sebagai jenis implementasi layanan yang Singleton ditentukan dalam TImplementation jika collection jenis layanan belum terdaftar.

public:
generic <typename TService, typename TImplementation>
 where TService : class where TImplementation : class, TService[System::Runtime::CompilerServices::Extension]
 static void TryAddKeyedSingleton(Microsoft::Extensions::DependencyInjection::IServiceCollection ^ collection, System::Object ^ serviceKey);
public static void TryAddKeyedSingleton<TService,TImplementation> (this Microsoft.Extensions.DependencyInjection.IServiceCollection collection, object? serviceKey) where TService : class where TImplementation : class, TService;
static member TryAddKeyedSingleton : Microsoft.Extensions.DependencyInjection.IServiceCollection * obj -> unit (requires 'Service : null)
<Extension()>
Public Sub TryAddKeyedSingleton(Of TService As Class, TImplementation As Class) (collection As IServiceCollection, serviceKey As Object)

Jenis parameter

TService

Jenis layanan yang akan ditambahkan.

TImplementation

Jenis implementasi yang akan digunakan.

Parameter

serviceKey
Object

Kunci layanan.

Berlaku untuk

TryAddKeyedSingleton<TService>(IServiceCollection, Object)

Sumber:
ServiceCollectionDescriptorExtensions.Keyed.cs
Sumber:
ServiceCollectionDescriptorExtensions.Keyed.cs
Sumber:
ServiceCollectionDescriptorExtensions.Keyed.cs
Sumber:
ServiceCollectionDescriptorExtensions.Keyed.cs

Menambahkan yang ditentukan TService sebagai Singleton layanan ke collection jika jenis layanan belum terdaftar.

public:
generic <typename TService>
 where TService : class[System::Runtime::CompilerServices::Extension]
 static void TryAddKeyedSingleton(Microsoft::Extensions::DependencyInjection::IServiceCollection ^ collection, System::Object ^ serviceKey);
public static void TryAddKeyedSingleton<TService> (this Microsoft.Extensions.DependencyInjection.IServiceCollection collection, object? serviceKey) where TService : class;
static member TryAddKeyedSingleton : Microsoft.Extensions.DependencyInjection.IServiceCollection * obj -> unit (requires 'Service : null)
<Extension()>
Public Sub TryAddKeyedSingleton(Of TService As Class) (collection As IServiceCollection, serviceKey As Object)

Jenis parameter

TService

Jenis layanan yang akan ditambahkan.

Parameter

serviceKey
Object

Kunci layanan.

Berlaku untuk

TryAddKeyedSingleton<TService>(IServiceCollection, Object, Func<IServiceProvider,Object,TService>)

Sumber:
ServiceCollectionDescriptorExtensions.Keyed.cs
Sumber:
ServiceCollectionDescriptorExtensions.Keyed.cs
Sumber:
ServiceCollectionDescriptorExtensions.Keyed.cs
Sumber:
ServiceCollectionDescriptorExtensions.Keyed.cs

Menambahkan yang ditentukan TService sebagai Singleton layanan menggunakan pabrik yang ditentukan ke implementationFactoryservices jika jenis layanan belum terdaftar.

public:
generic <typename TService>
 where TService : class[System::Runtime::CompilerServices::Extension]
 static void TryAddKeyedSingleton(Microsoft::Extensions::DependencyInjection::IServiceCollection ^ services, System::Object ^ serviceKey, Func<IServiceProvider ^, System::Object ^, TService> ^ implementationFactory);
public static void TryAddKeyedSingleton<TService> (this Microsoft.Extensions.DependencyInjection.IServiceCollection services, object? serviceKey, Func<IServiceProvider,object?,TService> implementationFactory) where TService : class;
static member TryAddKeyedSingleton : Microsoft.Extensions.DependencyInjection.IServiceCollection * obj * Func<IServiceProvider, obj, 'Service (requires 'Service : null)> -> unit (requires 'Service : null)
<Extension()>
Public Sub TryAddKeyedSingleton(Of TService As Class) (services As IServiceCollection, serviceKey As Object, implementationFactory As Func(Of IServiceProvider, Object, TService))

Jenis parameter

TService

Jenis layanan yang akan ditambahkan.

Parameter

serviceKey
Object

Kunci layanan.

implementationFactory
Func<IServiceProvider,Object,TService>

Pabrik yang membuat layanan.

Berlaku untuk

TryAddKeyedSingleton<TService>(IServiceCollection, Object, TService)

Sumber:
ServiceCollectionDescriptorExtensions.Keyed.cs
Sumber:
ServiceCollectionDescriptorExtensions.Keyed.cs
Sumber:
ServiceCollectionDescriptorExtensions.Keyed.cs
Sumber:
ServiceCollectionDescriptorExtensions.Keyed.cs

Menambahkan yang ditentukan TService sebagai Singleton layanan dengan instans yang ditentukan ke instancecollection jika jenis layanan belum terdaftar.

public:
generic <typename TService>
 where TService : class[System::Runtime::CompilerServices::Extension]
 static void TryAddKeyedSingleton(Microsoft::Extensions::DependencyInjection::IServiceCollection ^ collection, System::Object ^ serviceKey, TService instance);
public static void TryAddKeyedSingleton<TService> (this Microsoft.Extensions.DependencyInjection.IServiceCollection collection, object? serviceKey, TService instance) where TService : class;
static member TryAddKeyedSingleton : Microsoft.Extensions.DependencyInjection.IServiceCollection * obj * 'Service -> unit (requires 'Service : null)
<Extension()>
Public Sub TryAddKeyedSingleton(Of TService As Class) (collection As IServiceCollection, serviceKey As Object, instance As TService)

Jenis parameter

TService

Jenis layanan yang akan ditambahkan.

Parameter

serviceKey
Object

Kunci layanan.

instance
TService

Instans layanan yang akan ditambahkan.

Berlaku untuk