共用方式為


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)

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>)

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)

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>()

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>)

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>)

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)

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

實作服務的物件。

傳回

地圖,讓進一步的呼叫可以鏈結。

適用於