ServiceCollectionDescriptorExtensions.TryAddKeyedSingleton Metodo
Definizione
Importante
Alcune informazioni sono relative alla release non definitiva del prodotto, che potrebbe subire modifiche significative prima della release definitiva. Microsoft non riconosce alcuna garanzia, espressa o implicita, in merito alle informazioni qui fornite.
Overload
TryAddKeyedSingleton(IServiceCollection, Type, Object) |
Aggiunge l'oggetto |
TryAddKeyedSingleton(IServiceCollection, Type, Object, Func<IServiceProvider,Object,Object>) |
Aggiunge l'oggetto |
TryAddKeyedSingleton(IServiceCollection, Type, Object, Type) |
Aggiunge l'oggetto |
TryAddKeyedSingleton<TService,TImplementation>(IServiceCollection, Object) |
Aggiunge l'oggetto |
TryAddKeyedSingleton<TService>(IServiceCollection, Object) |
Aggiunge l'oggetto |
TryAddKeyedSingleton<TService>(IServiceCollection, Object, Func<IServiceProvider,Object,TService>) |
Aggiunge l'oggetto |
TryAddKeyedSingleton<TService>(IServiceCollection, Object, TService) |
Aggiunge l'oggetto |
TryAddKeyedSingleton(IServiceCollection, Type, Object)
Aggiunge l'oggetto service
specificato come servizio Singleton a collection
se il tipo di servizio non è già stato registrato.
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)
Parametri
- collection
- IServiceCollection
Oggetto IServiceCollection.
- service
- Type
Tipo di servizio da registrare.
- serviceKey
- Object
Chiave del servizio.
Si applica a
TryAddKeyedSingleton(IServiceCollection, Type, Object, Func<IServiceProvider,Object,Object>)
Aggiunge l'oggetto service
specificato come servizio Singleton usando la factory specificata in implementationFactory
a collection
se il tipo di servizio non è già stato registrato.
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))
Parametri
- collection
- IServiceCollection
Oggetto IServiceCollection.
- service
- Type
Tipo di servizio da registrare.
- serviceKey
- Object
Chiave del servizio.
- implementationFactory
- Func<IServiceProvider,Object,Object>
Factory che crea il servizio.
Si applica a
TryAddKeyedSingleton(IServiceCollection, Type, Object, Type)
Aggiunge l'oggetto service
specificato come servizio Singleton con l'implementazione di implementationType
a collection
se il tipo di servizio non è già stato registrato.
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)
Parametri
- collection
- IServiceCollection
Oggetto IServiceCollection.
- service
- Type
Tipo di servizio da registrare.
- serviceKey
- Object
Chiave del servizio.
- implementationType
- Type
Tipo di implementazione del servizio.
Si applica a
TryAddKeyedSingleton<TService,TImplementation>(IServiceCollection, Object)
Aggiunge l'oggetto TService
specificato come tipo di implementazione del servizio Singleton specificato in TImplementation
a collection
se il tipo di servizio non è già stato registrato.
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)
Parametri di tipo
- TService
Tipo del servizio da aggiungere.
- TImplementation
Tipo dell'implementazione da usare.
Parametri
- collection
- IServiceCollection
Oggetto IServiceCollection.
- serviceKey
- Object
Chiave del servizio.
Si applica a
TryAddKeyedSingleton<TService>(IServiceCollection, Object)
Aggiunge l'oggetto TService
specificato come servizio Singleton a collection
se il tipo di servizio non è già stato registrato.
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)
Parametri di tipo
- TService
Tipo del servizio da aggiungere.
Parametri
- collection
- IServiceCollection
Oggetto IServiceCollection.
- serviceKey
- Object
Chiave del servizio.
Si applica a
TryAddKeyedSingleton<TService>(IServiceCollection, Object, Func<IServiceProvider,Object,TService>)
Aggiunge l'oggetto TService
specificato come servizio Singleton usando la factory specificata in implementationFactory
a services
se il tipo di servizio non è già stato registrato.
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))
Parametri di tipo
- TService
Tipo del servizio da aggiungere.
Parametri
- services
- IServiceCollection
Oggetto IServiceCollection.
- serviceKey
- Object
Chiave del servizio.
- implementationFactory
- Func<IServiceProvider,Object,TService>
Factory che crea il servizio.
Si applica a
TryAddKeyedSingleton<TService>(IServiceCollection, Object, TService)
Aggiunge l'oggetto TService
specificato come servizio Singleton con un'istanza specificata in instance
a collection
se il tipo di servizio non è già stato registrato.
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)
Parametri di tipo
- TService
Tipo del servizio da aggiungere.
Parametri
- collection
- IServiceCollection
Oggetto IServiceCollection.
- serviceKey
- Object
Chiave del servizio.
- instance
- TService
Istanza del servizio da aggiungere.