ServiceCollectionMap.TryAdd 方法

定义

重载

TryAdd(Type, Func<IServiceProvider,Object>, ServiceLifetime)

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

TryAdd(Type, Type, ServiceLifetime)

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

TryAdd(Type, Func<IServiceProvider,Object>, ServiceLifetime)

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

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

参数

serviceType
Type

服务的协定。

factory
Func<IServiceProvider,Object>

实现服务的工厂。

lifetime
ServiceLifetime

服务生存期。

返回

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

适用于

TryAdd(Type, Type, ServiceLifetime)

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

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

参数

serviceType
Type

服务的协定。

implementationType
Type

实现服务的具体类型。

lifetime
ServiceLifetime

服务生存期。

返回

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

适用于