ServiceCollectionServiceExtensions.AddScoped ServiceCollectionServiceExtensions.AddScoped ServiceCollectionServiceExtensions.AddScoped Method

Definition

Overloads

AddScoped(IServiceCollection, Type) AddScoped(IServiceCollection, Type) AddScoped(IServiceCollection, Type)

Adds a scoped service of the type specified in serviceType to the specified IServiceCollection.

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

Adds a scoped service of the type specified in serviceType with a factory specified in implementationFactory to the specified IServiceCollection.

AddScoped(IServiceCollection, Type, Type) AddScoped(IServiceCollection, Type, Type) AddScoped(IServiceCollection, Type, Type)

Adds a scoped service of the type specified in serviceType with an implementation of the type specified in implementationType to the specified IServiceCollection.

AddScoped<TService,TImplementation>(IServiceCollection) AddScoped<TService,TImplementation>(IServiceCollection) AddScoped<TService,TImplementation>(IServiceCollection)

Adds a scoped service of the type specified in TService with an implementation type specified in TImplementation to the specified IServiceCollection.

AddScoped<TService,TImplementation>(IServiceCollection, Func<IServiceProvider,TImplementation>) AddScoped<TService,TImplementation>(IServiceCollection, Func<IServiceProvider,TImplementation>) AddScoped<TService,TImplementation>(IServiceCollection, Func<IServiceProvider,TImplementation>)

Adds a scoped service of the type specified in TService with an implementation type specified in TImplementation using the factory specified in implementationFactory to the specified IServiceCollection.

AddScoped<TService>(IServiceCollection) AddScoped<TService>(IServiceCollection) AddScoped<TService>(IServiceCollection)

Adds a scoped service of the type specified in TService to the specified IServiceCollection.

AddScoped<TService>(IServiceCollection, Func<IServiceProvider,TService>) AddScoped<TService>(IServiceCollection, Func<IServiceProvider,TService>) AddScoped<TService>(IServiceCollection, Func<IServiceProvider,TService>)

Adds a scoped service of the type specified in TService with a factory specified in implementationFactory to the specified IServiceCollection.

AddScoped(IServiceCollection, Type) AddScoped(IServiceCollection, Type) AddScoped(IServiceCollection, Type)

Adds a scoped service of the type specified in serviceType to the specified IServiceCollection.

public static Microsoft.Extensions.DependencyInjection.IServiceCollection AddScoped (this Microsoft.Extensions.DependencyInjection.IServiceCollection services, Type serviceType);
static member AddScoped : Microsoft.Extensions.DependencyInjection.IServiceCollection * Type -> Microsoft.Extensions.DependencyInjection.IServiceCollection
<Extension()>
Public Function AddScoped (services As IServiceCollection, serviceType As Type) As IServiceCollection

Parameters

serviceType
Type Type Type

The type of the service to register and the implementation to use.

Returns

A reference to this instance after the operation has completed.

See also

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

Adds a scoped service of the type specified in serviceType with a factory specified in implementationFactory to the specified IServiceCollection.

public static Microsoft.Extensions.DependencyInjection.IServiceCollection AddScoped (this Microsoft.Extensions.DependencyInjection.IServiceCollection services, Type serviceType, Func<IServiceProvider,object> implementationFactory);
static member AddScoped : Microsoft.Extensions.DependencyInjection.IServiceCollection * Type * Func<IServiceProvider, obj> -> Microsoft.Extensions.DependencyInjection.IServiceCollection
<Extension()>
Public Function AddScoped (services As IServiceCollection, serviceType As Type, implementationFactory As Func(Of IServiceProvider, Object)) As IServiceCollection

Parameters

serviceType
Type Type Type

The type of the service to register.

implementationFactory
Func<IServiceProvider,Object>

The factory that creates the service.

Returns

A reference to this instance after the operation has completed.

See also

AddScoped(IServiceCollection, Type, Type) AddScoped(IServiceCollection, Type, Type) AddScoped(IServiceCollection, Type, Type)

Adds a scoped service of the type specified in serviceType with an implementation of the type specified in implementationType to the specified IServiceCollection.

public static Microsoft.Extensions.DependencyInjection.IServiceCollection AddScoped (this Microsoft.Extensions.DependencyInjection.IServiceCollection services, Type serviceType, Type implementationType);
static member AddScoped : Microsoft.Extensions.DependencyInjection.IServiceCollection * Type * Type -> Microsoft.Extensions.DependencyInjection.IServiceCollection
<Extension()>
Public Function AddScoped (services As IServiceCollection, serviceType As Type, implementationType As Type) As IServiceCollection

Parameters

serviceType
Type Type Type

The type of the service to register.

implementationType
Type Type Type

The implementation type of the service.

Returns

A reference to this instance after the operation has completed.

See also

AddScoped<TService,TImplementation>(IServiceCollection) AddScoped<TService,TImplementation>(IServiceCollection) AddScoped<TService,TImplementation>(IServiceCollection)

Adds a scoped service of the type specified in TService with an implementation type specified in TImplementation to the specified IServiceCollection.

public static Microsoft.Extensions.DependencyInjection.IServiceCollection AddScoped<TService,TImplementation> (this Microsoft.Extensions.DependencyInjection.IServiceCollection services) where TService : class where TImplementation : class, TService;
static member AddScoped : Microsoft.Extensions.DependencyInjection.IServiceCollection -> Microsoft.Extensions.DependencyInjection.IServiceCollection (requires 'Service : null)
<Extension()>
Public Function AddScoped(Of TService As Class, TImplementation As Class) (services As IServiceCollection) As IServiceCollection

Type Parameters

TService

The type of the service to add.

TImplementation

The type of the implementation to use.

Parameters

Returns

A reference to this instance after the operation has completed.

See also

AddScoped<TService,TImplementation>(IServiceCollection, Func<IServiceProvider,TImplementation>) AddScoped<TService,TImplementation>(IServiceCollection, Func<IServiceProvider,TImplementation>) AddScoped<TService,TImplementation>(IServiceCollection, Func<IServiceProvider,TImplementation>)

Adds a scoped service of the type specified in TService with an implementation type specified in TImplementation using the factory specified in implementationFactory to the specified IServiceCollection.

public static Microsoft.Extensions.DependencyInjection.IServiceCollection AddScoped<TService,TImplementation> (this Microsoft.Extensions.DependencyInjection.IServiceCollection services, Func<IServiceProvider,TImplementation> implementationFactory) where TService : class where TImplementation : class, TService;
static member AddScoped : Microsoft.Extensions.DependencyInjection.IServiceCollection * Func<IServiceProvider, #'Service> -> Microsoft.Extensions.DependencyInjection.IServiceCollection (requires 'Service : null)
<Extension()>
Public Function AddScoped(Of TService As Class, TImplementation As Class) (services As IServiceCollection, implementationFactory As Func(Of IServiceProvider, TImplementation)) As IServiceCollection

Type Parameters

TService

The type of the service to add.

TImplementation

The type of the implementation to use.

Parameters

implementationFactory
Func<IServiceProvider,TImplementation>

The factory that creates the service.

Returns

A reference to this instance after the operation has completed.

See also

AddScoped<TService>(IServiceCollection) AddScoped<TService>(IServiceCollection) AddScoped<TService>(IServiceCollection)

Adds a scoped service of the type specified in TService to the specified IServiceCollection.

public static Microsoft.Extensions.DependencyInjection.IServiceCollection AddScoped<TService> (this Microsoft.Extensions.DependencyInjection.IServiceCollection services) where TService : class;
static member AddScoped : Microsoft.Extensions.DependencyInjection.IServiceCollection -> Microsoft.Extensions.DependencyInjection.IServiceCollection (requires 'Service : null)
<Extension()>
Public Function AddScoped(Of TService As Class) (services As IServiceCollection) As IServiceCollection

Type Parameters

TService

The type of the service to add.

Parameters

Returns

A reference to this instance after the operation has completed.

See also

AddScoped<TService>(IServiceCollection, Func<IServiceProvider,TService>) AddScoped<TService>(IServiceCollection, Func<IServiceProvider,TService>) AddScoped<TService>(IServiceCollection, Func<IServiceProvider,TService>)

Adds a scoped service of the type specified in TService with a factory specified in implementationFactory to the specified IServiceCollection.

public static Microsoft.Extensions.DependencyInjection.IServiceCollection AddScoped<TService> (this Microsoft.Extensions.DependencyInjection.IServiceCollection services, Func<IServiceProvider,TService> implementationFactory) where TService : class;
static member AddScoped : Microsoft.Extensions.DependencyInjection.IServiceCollection * Func<IServiceProvider, 'Service (requires 'Service : null)> -> Microsoft.Extensions.DependencyInjection.IServiceCollection (requires 'Service : null)
<Extension()>
Public Function AddScoped(Of TService As Class) (services As IServiceCollection, implementationFactory As Func(Of IServiceProvider, TService)) As IServiceCollection

Type Parameters

TService

The type of the service to add.

Parameters

implementationFactory
Func<IServiceProvider,TService>

The factory that creates the service.

Returns

A reference to this instance after the operation has completed.

See also

Applies to