Share via


IKeyedServiceCollection<TKey,TService> 介面

定義

可透過索引鍵釐清的服務集合

public interface IKeyedServiceCollection<in TKey,out TService> where TService : class
public interface IKeyedServiceCollection<TKey,out TService> where TService : class
type IKeyedServiceCollection<'Key, 'Service (requires 'Service : null)> = interface
Public Interface IKeyedServiceCollection(Of In TKey, Out TService)
Public Interface IKeyedServiceCollection(Of TKey, Out TService)

類型參數

TKey

服務金鑰類型。

這是反變數的型別參數。 也就是說,您可以使用您指定的類型,或衍生程度較低的任何類型。 如需共變數與反變數的詳細資訊,請參閱泛型中的共變數與反變數
TService

服務類型。

這是共變數的型別參數。 也就是說,您可以使用您指定的類型,或衍生程度較高的任何類型。 如需共變數與反變數的詳細資訊,請參閱泛型中的共變數與反變數
衍生

方法

GetService(IServiceProvider, TKey)

取得具有指定索引鍵的服務。

GetService(TKey)

可透過索引鍵釐清的服務集合

GetServices(IServiceProvider)

從這個集合取得所有服務。

適用於