ServiceCollectionMap.TryAddScoped 方法

定义

重载

TryAddScoped(Type, Func<IServiceProvider,Object>)

Scoped如果尚未为给定服务类型注册任何服务,则添加由给定工厂实现的服务。

TryAddScoped(Type, Type)

Scoped如果尚未为给定服务类型注册任何服务,则添加由给定具体类型实现的服务。

TryAddScoped<TService,TImplementation>()

Scoped如果尚未为给定服务类型注册任何服务,则添加由给定具体类型实现的服务。

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

Scoped如果尚未为给定服务类型注册任何服务,则添加由给定工厂实现的服务。

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

Scoped如果尚未为给定服务类型注册任何服务,则添加由给定工厂实现的服务。

TryAddScoped(Type, Func<IServiceProvider,Object>)

Scoped如果尚未为给定服务类型注册任何服务,则添加由给定工厂实现的服务。

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

参数

serviceType
Type

服务的协定。

factory
Func<IServiceProvider,Object>

实现服务的工厂。

返回

映射,以便可以链接进一步的调用。

适用于

TryAddScoped(Type, Type)

Scoped如果尚未为给定服务类型注册任何服务,则添加由给定具体类型实现的服务。

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

参数

serviceType
Type

服务的协定。

implementationType
Type

实现服务的具体类型。

返回

映射,以便可以链接进一步的调用。

适用于

TryAddScoped<TService,TImplementation>()

Scoped如果尚未为给定服务类型注册任何服务,则添加由给定具体类型实现的服务。

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

类型参数

TService

服务的协定。

TImplementation

实现服务的具体类型。

返回

映射,以便可以链接进一步的调用。

适用于

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

Scoped如果尚未为给定服务类型注册任何服务,则添加由给定工厂实现的服务。

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

类型参数

TService

服务的协定。

TImplementation

给定工厂创建的具体类型。

参数

factory
Func<IServiceProvider,TImplementation>

实现服务的工厂。

返回

映射,以便可以链接进一步的调用。

适用于

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

Scoped如果尚未为给定服务类型注册任何服务,则添加由给定工厂实现的服务。

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

类型参数

TService

服务的协定。

参数

factory
Func<IServiceProvider,TService>

实现服务的工厂。

返回

映射,以便可以链接进一步的调用。

适用于