ServiceCollectionMap.TryAddSingleton 方法

定义

重载

TryAddSingleton(Type, Type)

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

TryAddSingleton(Type, Func<IServiceProvider,Object>)

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

TryAddSingleton(Type, Object)

Singleton如果尚未注册给定服务类型的服务,则添加由给定实例实现的服务。

TryAddSingleton<TService,TImplementation>()

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

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

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

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

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

TryAddSingleton<TService>(TService)

Singleton如果尚未注册给定服务类型的服务,则添加由给定实例实现的服务。

TryAddSingleton(Type, Type)

Source:
ServiceCollectionMap.cs
Source:
ServiceCollectionMap.cs
Source:
ServiceCollectionMap.cs
Source:
ServiceCollectionMap.cs
Source:
ServiceCollectionMap.cs
Source:
ServiceCollectionMap.cs
Source:
ServiceCollectionMap.cs
Source:
ServiceCollectionMap.cs
Source:
ServiceCollectionMap.cs

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

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

参数

serviceType
Type

服务的协定。

implementationType
Type

实现服务的具体类型。

返回

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

适用于

TryAddSingleton(Type, Func<IServiceProvider,Object>)

Source:
ServiceCollectionMap.cs
Source:
ServiceCollectionMap.cs
Source:
ServiceCollectionMap.cs
Source:
ServiceCollectionMap.cs
Source:
ServiceCollectionMap.cs
Source:
ServiceCollectionMap.cs
Source:
ServiceCollectionMap.cs
Source:
ServiceCollectionMap.cs
Source:
ServiceCollectionMap.cs

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

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

参数

serviceType
Type

服务的协定。

factory
Func<IServiceProvider,Object>

实现服务的工厂。

返回

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

适用于

TryAddSingleton(Type, Object)

Source:
ServiceCollectionMap.cs
Source:
ServiceCollectionMap.cs
Source:
ServiceCollectionMap.cs
Source:
ServiceCollectionMap.cs
Source:
ServiceCollectionMap.cs
Source:
ServiceCollectionMap.cs
Source:
ServiceCollectionMap.cs
Source:
ServiceCollectionMap.cs
Source:
ServiceCollectionMap.cs

Singleton如果尚未注册给定服务类型的服务,则添加由给定实例实现的服务。

public virtual Microsoft.EntityFrameworkCore.Infrastructure.ServiceCollectionMap TryAddSingleton (Type serviceType, object implementation);
abstract member TryAddSingleton : Type * obj -> Microsoft.EntityFrameworkCore.Infrastructure.ServiceCollectionMap
override this.TryAddSingleton : Type * obj -> Microsoft.EntityFrameworkCore.Infrastructure.ServiceCollectionMap
Public Overridable Function TryAddSingleton (serviceType As Type, implementation As Object) As ServiceCollectionMap

参数

serviceType
Type

服务的协定。

implementation
Object

实现服务的对象。

返回

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

适用于

TryAddSingleton<TService,TImplementation>()

Source:
ServiceCollectionMap.cs
Source:
ServiceCollectionMap.cs
Source:
ServiceCollectionMap.cs
Source:
ServiceCollectionMap.cs
Source:
ServiceCollectionMap.cs
Source:
ServiceCollectionMap.cs
Source:
ServiceCollectionMap.cs
Source:
ServiceCollectionMap.cs
Source:
ServiceCollectionMap.cs

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

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

类型参数

TService

服务的协定。

TImplementation

实现服务的具体类型。

返回

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

适用于

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

Source:
ServiceCollectionMap.cs
Source:
ServiceCollectionMap.cs
Source:
ServiceCollectionMap.cs
Source:
ServiceCollectionMap.cs
Source:
ServiceCollectionMap.cs
Source:
ServiceCollectionMap.cs
Source:
ServiceCollectionMap.cs
Source:
ServiceCollectionMap.cs
Source:
ServiceCollectionMap.cs

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

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

类型参数

TService

服务的协定。

TImplementation

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

参数

factory
Func<IServiceProvider,TImplementation>

实现服务的工厂。

返回

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

适用于

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

Source:
ServiceCollectionMap.cs
Source:
ServiceCollectionMap.cs
Source:
ServiceCollectionMap.cs
Source:
ServiceCollectionMap.cs
Source:
ServiceCollectionMap.cs
Source:
ServiceCollectionMap.cs
Source:
ServiceCollectionMap.cs
Source:
ServiceCollectionMap.cs
Source:
ServiceCollectionMap.cs

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

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

类型参数

TService

服务的协定。

参数

factory
Func<IServiceProvider,TService>

实现服务的工厂。

返回

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

适用于

TryAddSingleton<TService>(TService)

Source:
ServiceCollectionMap.cs
Source:
ServiceCollectionMap.cs
Source:
ServiceCollectionMap.cs
Source:
ServiceCollectionMap.cs
Source:
ServiceCollectionMap.cs
Source:
ServiceCollectionMap.cs
Source:
ServiceCollectionMap.cs
Source:
ServiceCollectionMap.cs
Source:
ServiceCollectionMap.cs

Singleton如果尚未注册给定服务类型的服务,则添加由给定实例实现的服务。

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

类型参数

TService

服务的协定。

参数

implementation
TService

实现服务的对象。

返回

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

适用于