ServiceCollectionDescriptorExtensions.TryAddScoped Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Overloads
TryAddScoped(IServiceCollection, Type) |
Adds the specified |
TryAddScoped(IServiceCollection, Type, Func<IServiceProvider,Object>) |
Adds the specified |
TryAddScoped(IServiceCollection, Type, Type) |
Adds the specified |
TryAddScoped<TService,TImplementation>(IServiceCollection) |
Adds the specified |
TryAddScoped<TService>(IServiceCollection) |
Adds the specified |
TryAddScoped<TService>(IServiceCollection, Func<IServiceProvider,TService>) |
Adds the specified |
TryAddScoped(IServiceCollection, Type)
Adds the specified service
as a Scoped service
to the collection
if the service type hasn't already been registered.
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)
Parameters
- collection
- IServiceCollection
The IServiceCollection.
- service
- Type
The type of the service to register.
Applies to
TryAddScoped(IServiceCollection, Type, Func<IServiceProvider,Object>)
Adds the specified service
as a Scoped service
using the factory specified in implementationFactory
to the collection
if the service type hasn't already been registered.
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))
Parameters
- collection
- IServiceCollection
The IServiceCollection.
- service
- Type
The type of the service to register.
- implementationFactory
- Func<IServiceProvider,Object>
The factory that creates the service.
Applies to
TryAddScoped(IServiceCollection, Type, Type)
Adds the specified service
as a Scoped service
with the implementationType
implementation
to the collection
if the service type hasn't already been registered.
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)
Parameters
- collection
- IServiceCollection
The IServiceCollection.
- service
- Type
The type of the service to register.
- implementationType
- Type
The implementation type of the service.
Applies to
TryAddScoped<TService,TImplementation>(IServiceCollection)
Adds the specified TService
as a Scoped service
implementation type specified in TImplementation
to the collection
if the service type hasn't already been registered.
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)
Type Parameters
- TService
The type of the service to add.
- TImplementation
The type of the implementation to use.
Parameters
- collection
- IServiceCollection
The IServiceCollection.
Applies to
TryAddScoped<TService>(IServiceCollection)
Adds the specified TService
as a Scoped service
to the collection
if the service type hasn't already been registered.
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)
Type Parameters
- TService
The type of the service to add.
Parameters
- collection
- IServiceCollection
The IServiceCollection.
Applies to
TryAddScoped<TService>(IServiceCollection, Func<IServiceProvider,TService>)
Adds the specified TService
as a Scoped service
using the factory specified in implementationFactory
to the services
if the service type hasn't already been registered.
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))
Type Parameters
- TService
The type of the service to add.
Parameters
- services
- IServiceCollection
The IServiceCollection.
- implementationFactory
- Func<IServiceProvider,TService>
The factory that creates the service.