共用方式為


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>

實作服務的處理站。

傳回

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

適用於