ServiceCollectionDescriptorExtensions.TryAddScoped Metod
Definition
Viktigt
En del information gäller för förhandsversionen av en produkt och kan komma att ändras avsevärt innan produkten blir allmänt tillgänglig. Microsoft lämnar inga garantier, uttryckliga eller underförstådda, avseende informationen som visas här.
Överlagringar
| Name | Description |
|---|---|
| TryAddScoped(IServiceCollection, Type) |
Lägger till den angivna |
| TryAddScoped(IServiceCollection, Type, Func<IServiceProvider,Object>) |
Lägger till den angivna |
| TryAddScoped(IServiceCollection, Type, Type) |
Lägger till den angivna |
| TryAddScoped<TService,TImplementation>(IServiceCollection) |
Lägger till den angivna |
| TryAddScoped<TService>(IServiceCollection) |
Lägger till den angivna |
| TryAddScoped<TService>(IServiceCollection, Func<IServiceProvider,TService>) |
Lägger till den angivna |
TryAddScoped(IServiceCollection, Type)
Lägger till den angivna service som en Scoped tjänst i collection om tjänsttypen inte redan har registrerats.
public:
[System::Runtime::CompilerServices::Extension]
static void TryAddScoped(Microsoft::Extensions::DependencyInjection::IServiceCollection ^ collection, Type ^ service);
public static void TryAddScoped(this Microsoft.Extensions.DependencyInjection.IServiceCollection collection, Type service);
static member TryAddScoped : Microsoft.Extensions.DependencyInjection.IServiceCollection * Type -> unit
<Extension()>
Public Sub TryAddScoped (collection As IServiceCollection, service As Type)
Parametrar
- collection
- IServiceCollection
- service
- Type
Vilken typ av tjänst som ska registreras.
Se även
Gäller för
TryAddScoped(IServiceCollection, Type, Func<IServiceProvider,Object>)
Lägger till den angivna service som en Scoped tjänst med den fabrik som anges i implementationFactorycollection i om tjänsttypen inte redan har registrerats.
public:
[System::Runtime::CompilerServices::Extension]
static void TryAddScoped(Microsoft::Extensions::DependencyInjection::IServiceCollection ^ collection, Type ^ service, Func<IServiceProvider ^, System::Object ^> ^ implementationFactory);
public static void TryAddScoped(this Microsoft.Extensions.DependencyInjection.IServiceCollection collection, Type service, Func<IServiceProvider,object> implementationFactory);
static member TryAddScoped : Microsoft.Extensions.DependencyInjection.IServiceCollection * Type * Func<IServiceProvider, obj> -> unit
<Extension()>
Public Sub TryAddScoped (collection As IServiceCollection, service As Type, implementationFactory As Func(Of IServiceProvider, Object))
Parametrar
- collection
- IServiceCollection
- service
- Type
Vilken typ av tjänst som ska registreras.
- implementationFactory
- Func<IServiceProvider,Object>
Fabriken som skapar tjänsten.
Se även
Gäller för
TryAddScoped(IServiceCollection, Type, Type)
Lägger till den angivna service som en Scoped tjänst med implementeringen implementationType till collection om tjänsttypen inte redan har registrerats.
public:
[System::Runtime::CompilerServices::Extension]
static void TryAddScoped(Microsoft::Extensions::DependencyInjection::IServiceCollection ^ collection, Type ^ service, Type ^ implementationType);
public static void TryAddScoped(this Microsoft.Extensions.DependencyInjection.IServiceCollection collection, Type service, Type implementationType);
static member TryAddScoped : Microsoft.Extensions.DependencyInjection.IServiceCollection * Type * Type -> unit
<Extension()>
Public Sub TryAddScoped (collection As IServiceCollection, service As Type, implementationType As Type)
Parametrar
- collection
- IServiceCollection
- service
- Type
Vilken typ av tjänst som ska registreras.
- implementationType
- Type
Implementeringstypen för tjänsten.
Se även
Gäller för
TryAddScoped<TService,TImplementation>(IServiceCollection)
Lägger till den angivna TService som en Scoped tjänstimplementeringstyp som anges i TImplementationcollection om tjänsttypen inte redan har registrerats.
public:
generic <typename TService, typename TImplementation>
where TService : class where TImplementation : class, TService[System::Runtime::CompilerServices::Extension]
static void TryAddScoped(Microsoft::Extensions::DependencyInjection::IServiceCollection ^ collection);
public static void TryAddScoped<TService,TImplementation>(this Microsoft.Extensions.DependencyInjection.IServiceCollection collection) where TService : class where TImplementation : class, TService;
static member TryAddScoped : Microsoft.Extensions.DependencyInjection.IServiceCollection -> unit (requires 'Service : null)
<Extension()>
Public Sub TryAddScoped(Of TService As Class, TImplementation As Class) (collection As IServiceCollection)
Typparametrar
- TService
Vilken typ av tjänst som ska läggas till.
- TImplementation
Vilken typ av implementering som ska användas.
Parametrar
- collection
- IServiceCollection
Se även
Gäller för
TryAddScoped<TService>(IServiceCollection)
Lägger till den angivna TService som en Scoped tjänst i collection om tjänsttypen inte redan har registrerats.
public:
generic <typename TService>
where TService : class[System::Runtime::CompilerServices::Extension]
static void TryAddScoped(Microsoft::Extensions::DependencyInjection::IServiceCollection ^ collection);
public static void TryAddScoped<TService>(this Microsoft.Extensions.DependencyInjection.IServiceCollection collection) where TService : class;
static member TryAddScoped : Microsoft.Extensions.DependencyInjection.IServiceCollection -> unit (requires 'Service : null)
<Extension()>
Public Sub TryAddScoped(Of TService As Class) (collection As IServiceCollection)
Typparametrar
- TService
Vilken typ av tjänst som ska läggas till.
Parametrar
- collection
- IServiceCollection
Se även
Gäller för
TryAddScoped<TService>(IServiceCollection, Func<IServiceProvider,TService>)
Lägger till den angivna TService som en Scoped tjänst med den fabrik som anges i implementationFactoryservices i om tjänsttypen inte redan har registrerats.
public:
generic <typename TService>
where TService : class[System::Runtime::CompilerServices::Extension]
static void TryAddScoped(Microsoft::Extensions::DependencyInjection::IServiceCollection ^ services, Func<IServiceProvider ^, TService> ^ implementationFactory);
public static void TryAddScoped<TService>(this Microsoft.Extensions.DependencyInjection.IServiceCollection services, Func<IServiceProvider,TService> implementationFactory) where TService : class;
static member TryAddScoped : Microsoft.Extensions.DependencyInjection.IServiceCollection * Func<IServiceProvider, 'Service (requires 'Service : null)> -> unit (requires 'Service : null)
<Extension()>
Public Sub TryAddScoped(Of TService As Class) (services As IServiceCollection, implementationFactory As Func(Of IServiceProvider, TService))
Typparametrar
- TService
Vilken typ av tjänst som ska läggas till.
Parametrar
- services
- IServiceCollection
- implementationFactory
- Func<IServiceProvider,TService>
Fabriken som skapar tjänsten.