ServiceCollectionDescriptorExtensions.TryAddSingleton 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
TryAddSingleton(IServiceCollection, Type, Type) |
Aggiunge l'oggetto |
TryAddSingleton(IServiceCollection, Type, Func<IServiceProvider,Object>) |
Aggiunge l'oggetto |
TryAddSingleton(IServiceCollection, Type) |
Aggiunge l'oggetto |
TryAddSingleton<TService,TImplementation>(IServiceCollection) |
Aggiunge l'oggetto |
TryAddSingleton<TService>(IServiceCollection) |
Aggiunge l'oggetto |
TryAddSingleton<TService>(IServiceCollection, Func<IServiceProvider,TService>) |
Aggiunge l'oggetto |
TryAddSingleton<TService>(IServiceCollection, TService) |
Aggiunge l'oggetto |
TryAddSingleton(IServiceCollection, Type, 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 TryAddSingleton(Microsoft::Extensions::DependencyInjection::IServiceCollection ^ collection, Type ^ service, Type ^ implementationType);
public static void TryAddSingleton (this Microsoft.Extensions.DependencyInjection.IServiceCollection collection, Type service, Type implementationType);
static member TryAddSingleton : Microsoft.Extensions.DependencyInjection.IServiceCollection * Type * Type -> unit
<Extension()>
Public Sub TryAddSingleton (collection As IServiceCollection, service As Type, implementationType As Type)
Parametri
- collection
- IServiceCollection
Oggetto IServiceCollection.
- service
- Type
Tipo di servizio da registrare.
- implementationType
- Type
Tipo di implementazione del servizio.
Si applica a
TryAddSingleton(IServiceCollection, Type, Func<IServiceProvider,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 TryAddSingleton(Microsoft::Extensions::DependencyInjection::IServiceCollection ^ collection, Type ^ service, Func<IServiceProvider ^, System::Object ^> ^ implementationFactory);
public static void TryAddSingleton (this Microsoft.Extensions.DependencyInjection.IServiceCollection collection, Type service, Func<IServiceProvider,object> implementationFactory);
static member TryAddSingleton : Microsoft.Extensions.DependencyInjection.IServiceCollection * Type * Func<IServiceProvider, obj> -> unit
<Extension()>
Public Sub TryAddSingleton (collection As IServiceCollection, service As Type, implementationFactory As Func(Of IServiceProvider, Object))
Parametri
- collection
- IServiceCollection
Oggetto IServiceCollection.
- service
- Type
Tipo di servizio da registrare.
- implementationFactory
- Func<IServiceProvider,Object>
Factory che crea il servizio.
Si applica a
TryAddSingleton(IServiceCollection, Type)
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 TryAddSingleton(Microsoft::Extensions::DependencyInjection::IServiceCollection ^ collection, Type ^ service);
public static void TryAddSingleton (this Microsoft.Extensions.DependencyInjection.IServiceCollection collection, Type service);
static member TryAddSingleton : Microsoft.Extensions.DependencyInjection.IServiceCollection * Type -> unit
<Extension()>
Public Sub TryAddSingleton (collection As IServiceCollection, service As Type)
Parametri
- collection
- IServiceCollection
Oggetto IServiceCollection.
- service
- Type
Tipo di servizio da registrare.
Si applica a
TryAddSingleton<TService,TImplementation>(IServiceCollection)
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 TryAddSingleton(Microsoft::Extensions::DependencyInjection::IServiceCollection ^ collection);
public static void TryAddSingleton<TService,TImplementation> (this Microsoft.Extensions.DependencyInjection.IServiceCollection collection) where TService : class where TImplementation : class, TService;
static member TryAddSingleton : Microsoft.Extensions.DependencyInjection.IServiceCollection -> unit (requires 'Service : null)
<Extension()>
Public Sub TryAddSingleton(Of TService As Class, TImplementation As Class) (collection As IServiceCollection)
Parametri di tipo
- TService
Tipo del servizio da aggiungere.
- TImplementation
Tipo dell'implementazione da usare.
Parametri
- collection
- IServiceCollection
Oggetto IServiceCollection.
Si applica a
TryAddSingleton<TService>(IServiceCollection)
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 TryAddSingleton(Microsoft::Extensions::DependencyInjection::IServiceCollection ^ collection);
public static void TryAddSingleton<TService> (this Microsoft.Extensions.DependencyInjection.IServiceCollection collection) where TService : class;
static member TryAddSingleton : Microsoft.Extensions.DependencyInjection.IServiceCollection -> unit (requires 'Service : null)
<Extension()>
Public Sub TryAddSingleton(Of TService As Class) (collection As IServiceCollection)
Parametri di tipo
- TService
Tipo del servizio da aggiungere.
Parametri
- collection
- IServiceCollection
Oggetto IServiceCollection.
Si applica a
TryAddSingleton<TService>(IServiceCollection, Func<IServiceProvider,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 TryAddSingleton(Microsoft::Extensions::DependencyInjection::IServiceCollection ^ services, Func<IServiceProvider ^, TService> ^ implementationFactory);
public static void TryAddSingleton<TService> (this Microsoft.Extensions.DependencyInjection.IServiceCollection services, Func<IServiceProvider,TService> implementationFactory) where TService : class;
static member TryAddSingleton : Microsoft.Extensions.DependencyInjection.IServiceCollection * Func<IServiceProvider, 'Service (requires 'Service : null)> -> unit (requires 'Service : null)
<Extension()>
Public Sub TryAddSingleton(Of TService As Class) (services As IServiceCollection, implementationFactory As Func(Of IServiceProvider, TService))
Parametri di tipo
- TService
Tipo del servizio da aggiungere.
Parametri
- services
- IServiceCollection
Oggetto IServiceCollection.
- implementationFactory
- Func<IServiceProvider,TService>
Factory che crea il servizio.
Si applica a
TryAddSingleton<TService>(IServiceCollection, 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 TryAddSingleton(Microsoft::Extensions::DependencyInjection::IServiceCollection ^ collection, TService instance);
public static void TryAddSingleton<TService> (this Microsoft.Extensions.DependencyInjection.IServiceCollection collection, TService instance) where TService : class;
static member TryAddSingleton : Microsoft.Extensions.DependencyInjection.IServiceCollection * 'Service -> unit (requires 'Service : null)
<Extension()>
Public Sub TryAddSingleton(Of TService As Class) (collection As IServiceCollection, instance As TService)
Parametri di tipo
- TService
Tipo del servizio da aggiungere.
Parametri
- collection
- IServiceCollection
Oggetto IServiceCollection.
- instance
- TService
Istanza del servizio da aggiungere.