Share via


ServiceCollectionMap.TryAddScoped Method

Definition

Overloads

TryAddScoped(Type, Func<IServiceProvider,Object>)

Adds a Scoped service implemented by the given factory if no service for the given service type has already been registered.

TryAddScoped(Type, Type)

Adds a Scoped service implemented by the given concrete type if no service for the given service type has already been registered.

TryAddScoped<TService,TImplementation>()

Adds a Scoped service implemented by the given concrete type if no service for the given service type has already been registered.

TryAddScoped<TService,TImplementation>(Func<IServiceProvider,TImplementation>)

Adds a Scoped service implemented by the given factory if no service for the given service type has already been registered.

TryAddScoped<TService>(Func<IServiceProvider,TService>)

Adds a Scoped service implemented by the given factory if no service for the given service type has already been registered.

TryAddScoped(Type, Func<IServiceProvider,Object>)

Adds a Scoped service implemented by the given factory if no service for the given service type has already been registered.

public virtual Microsoft.EntityFrameworkCore.Infrastructure.ServiceCollectionMap TryAddScoped (Type serviceType, Func<IServiceProvider,object> factory);
abstract member TryAddScoped : Type * Func<IServiceProvider, obj> -> Microsoft.EntityFrameworkCore.Infrastructure.ServiceCollectionMap
override this.TryAddScoped : Type * Func<IServiceProvider, obj> -> Microsoft.EntityFrameworkCore.Infrastructure.ServiceCollectionMap
Public Overridable Function TryAddScoped (serviceType As Type, factory As Func(Of IServiceProvider, Object)) As ServiceCollectionMap

Parameters

serviceType
Type

The contract for the service.

factory
Func<IServiceProvider,Object>

The factory that implements the service.

Returns

The map, such that further calls can be chained.

Applies to

TryAddScoped(Type, Type)

Adds a Scoped service implemented by the given concrete type if no service for the given service type has already been registered.

public virtual Microsoft.EntityFrameworkCore.Infrastructure.ServiceCollectionMap TryAddScoped (Type serviceType, Type implementationType);
abstract member TryAddScoped : Type * Type -> Microsoft.EntityFrameworkCore.Infrastructure.ServiceCollectionMap
override this.TryAddScoped : Type * Type -> Microsoft.EntityFrameworkCore.Infrastructure.ServiceCollectionMap
Public Overridable Function TryAddScoped (serviceType As Type, implementationType As Type) As ServiceCollectionMap

Parameters

serviceType
Type

The contract for the service.

implementationType
Type

The concrete type that implements the service.

Returns

The map, such that further calls can be chained.

Applies to

TryAddScoped<TService,TImplementation>()

Adds a Scoped service implemented by the given concrete type if no service for the given service type has already been registered.

public virtual Microsoft.EntityFrameworkCore.Infrastructure.ServiceCollectionMap TryAddScoped<TService,TImplementation> () where TService : class where TImplementation : class, TService;
abstract member TryAddScoped : unit -> Microsoft.EntityFrameworkCore.Infrastructure.ServiceCollectionMap (requires 'Service : null)
override this.TryAddScoped : unit -> Microsoft.EntityFrameworkCore.Infrastructure.ServiceCollectionMap (requires 'Service : null)
Public Overridable Function TryAddScoped(Of TService As Class, TImplementation As Class) () As ServiceCollectionMap

Type Parameters

TService

The contract for the service.

TImplementation

The concrete type that implements the service.

Returns

The map, such that further calls can be chained.

Applies to

TryAddScoped<TService,TImplementation>(Func<IServiceProvider,TImplementation>)

Adds a Scoped service implemented by the given factory if no service for the given service type has already been registered.

public virtual Microsoft.EntityFrameworkCore.Infrastructure.ServiceCollectionMap TryAddScoped<TService,TImplementation> (Func<IServiceProvider,TImplementation> factory) where TService : class where TImplementation : class, TService;
abstract member TryAddScoped : Func<IServiceProvider, #'Service> -> Microsoft.EntityFrameworkCore.Infrastructure.ServiceCollectionMap (requires 'Service : null)
override this.TryAddScoped : Func<IServiceProvider, #'Service> -> Microsoft.EntityFrameworkCore.Infrastructure.ServiceCollectionMap (requires 'Service : null)
Public Overridable Function TryAddScoped(Of TService As Class, TImplementation As Class) (factory As Func(Of IServiceProvider, TImplementation)) As ServiceCollectionMap

Type Parameters

TService

The contract for the service.

TImplementation

The concrete type that the given factory creates.

Parameters

factory
Func<IServiceProvider,TImplementation>

The factory that implements the service.

Returns

The map, such that further calls can be chained.

Applies to

TryAddScoped<TService>(Func<IServiceProvider,TService>)

Adds a Scoped service implemented by the given factory if no service for the given service type has already been registered.

public virtual Microsoft.EntityFrameworkCore.Infrastructure.ServiceCollectionMap TryAddScoped<TService> (Func<IServiceProvider,TService> factory) where TService : class;
abstract member TryAddScoped : Func<IServiceProvider, 'Service (requires 'Service : null)> -> Microsoft.EntityFrameworkCore.Infrastructure.ServiceCollectionMap (requires 'Service : null)
override this.TryAddScoped : Func<IServiceProvider, 'Service (requires 'Service : null)> -> Microsoft.EntityFrameworkCore.Infrastructure.ServiceCollectionMap (requires 'Service : null)
Public Overridable Function TryAddScoped(Of TService As Class) (factory As Func(Of IServiceProvider, TService)) As ServiceCollectionMap

Type Parameters

TService

The contract for the service.

Parameters

factory
Func<IServiceProvider,TService>

The factory that implements the service.

Returns

The map, such that further calls can be chained.

Applies to