次の方法で共有


ServiceCollectionServiceExtensions.AddKeyedSingleton メソッド

定義

オーバーロード

名前 説明
AddKeyedSingleton(IServiceCollection, Type, Object, Type)

implementationTypeで指定された型の実装を使用して、serviceTypeで指定された型のシングルトン サービスを、指定したIServiceCollectionに追加します。

AddKeyedSingleton(IServiceCollection, Type, Object, Object)

implementationInstanceで指定されたインスタンスを持つserviceTypeで指定された型のシングルトン サービスを、指定したIServiceCollectionに追加します。

AddKeyedSingleton(IServiceCollection, Type, Object)

serviceTypeで指定された型のシングルトン サービスを、指定したIServiceCollectionに追加します。

AddKeyedSingleton(IServiceCollection, Type, Object, Func<IServiceProvider,Object,Object>)

implementationFactoryで指定されたファクトリを使用して、serviceTypeで指定された型のシングルトン サービスを、指定したIServiceCollectionに追加します。

AddKeyedSingleton<TService,TImplementation>(IServiceCollection, Object)

TImplementationで指定された実装型を持つTServiceで指定された型のシングルトン サービスを、指定したIServiceCollectionに追加します。

AddKeyedSingleton<TService,TImplementation>(IServiceCollection, Object, Func<IServiceProvider,Object,TImplementation>)

implementationFactoryで指定されたファクトリを使用して、TImplementationで指定された実装型を持つ、TServiceで指定された型のシングルトン サービスを、指定したIServiceCollectionに追加します。

AddKeyedSingleton<TService>(IServiceCollection, Object)

TServiceで指定された型のシングルトン サービスを、指定したIServiceCollectionに追加します。

AddKeyedSingleton<TService>(IServiceCollection, Object, Func<IServiceProvider,Object,TService>)

implementationFactoryで指定されたファクトリを使用して、TServiceで指定された型のシングルトン サービスを、指定したIServiceCollectionに追加します。

AddKeyedSingleton<TService>(IServiceCollection, Object, TService)

implementationInstanceで指定されたインスタンスを持つTServiceで指定された型のシングルトン サービスを、指定したIServiceCollectionに追加します。

AddKeyedSingleton(IServiceCollection, Type, Object, Type)

ソース:
ServiceCollectionServiceExtensions.Keyed.cs
ソース:
ServiceCollectionServiceExtensions.Keyed.cs
ソース:
ServiceCollectionServiceExtensions.Keyed.cs
ソース:
ServiceCollectionServiceExtensions.Keyed.cs

implementationTypeで指定された型の実装を使用して、serviceTypeで指定された型のシングルトン サービスを、指定したIServiceCollectionに追加します。

public:
[System::Runtime::CompilerServices::Extension]
 static Microsoft::Extensions::DependencyInjection::IServiceCollection ^ AddKeyedSingleton(Microsoft::Extensions::DependencyInjection::IServiceCollection ^ services, Type ^ serviceType, System::Object ^ serviceKey, Type ^ implementationType);
public static Microsoft.Extensions.DependencyInjection.IServiceCollection AddKeyedSingleton(this Microsoft.Extensions.DependencyInjection.IServiceCollection services, Type serviceType, object? serviceKey, Type implementationType);
static member AddKeyedSingleton : Microsoft.Extensions.DependencyInjection.IServiceCollection * Type * obj * Type -> Microsoft.Extensions.DependencyInjection.IServiceCollection
<Extension()>
Public Function AddKeyedSingleton (services As IServiceCollection, serviceType As Type, serviceKey As Object, implementationType As Type) As IServiceCollection

パラメーター

services
IServiceCollection

サービスを追加する IServiceCollection

serviceType
Type

登録するサービスの種類。

serviceKey
Object

サービスの ServiceKey

implementationType
Type

サービスの実装の種類。

返品

操作が完了した後のこのインスタンスへの参照。

注釈

このメソッドは、同じ型とキーのサービスが既に登録されている場合でも、常に新しい登録を IServiceCollectionに追加します。 同じ型とキーに対して複数の登録が存在する場合、 GetKeyedService<T>(IServiceProvider, Object) は最後に登録されたサービスを返します。 GetKeyedServices<T>(IServiceProvider, Object)を使用して、登録されているすべてのサービスを取得します。

こちらもご覧ください

適用対象

AddKeyedSingleton(IServiceCollection, Type, Object, Object)

ソース:
ServiceCollectionServiceExtensions.Keyed.cs
ソース:
ServiceCollectionServiceExtensions.Keyed.cs
ソース:
ServiceCollectionServiceExtensions.Keyed.cs
ソース:
ServiceCollectionServiceExtensions.Keyed.cs

implementationInstanceで指定されたインスタンスを持つserviceTypeで指定された型のシングルトン サービスを、指定したIServiceCollectionに追加します。

public:
[System::Runtime::CompilerServices::Extension]
 static Microsoft::Extensions::DependencyInjection::IServiceCollection ^ AddKeyedSingleton(Microsoft::Extensions::DependencyInjection::IServiceCollection ^ services, Type ^ serviceType, System::Object ^ serviceKey, System::Object ^ implementationInstance);
public static Microsoft.Extensions.DependencyInjection.IServiceCollection AddKeyedSingleton(this Microsoft.Extensions.DependencyInjection.IServiceCollection services, Type serviceType, object? serviceKey, object implementationInstance);
static member AddKeyedSingleton : Microsoft.Extensions.DependencyInjection.IServiceCollection * Type * obj * obj -> Microsoft.Extensions.DependencyInjection.IServiceCollection
<Extension()>
Public Function AddKeyedSingleton (services As IServiceCollection, serviceType As Type, serviceKey As Object, implementationInstance As Object) As IServiceCollection

パラメーター

services
IServiceCollection

サービスを追加する IServiceCollection

serviceType
Type

登録するサービスの種類。

serviceKey
Object

サービスの ServiceKey

implementationInstance
Object

サービスのインスタンス。

返品

操作が完了した後のこのインスタンスへの参照。

注釈

このメソッドは、同じ型とキーのサービスが既に登録されている場合でも、常に新しい登録を IServiceCollectionに追加します。 同じ型とキーに対して複数の登録が存在する場合、 GetKeyedService<T>(IServiceProvider, Object) は最後に登録されたサービスを返します。 GetKeyedServices<T>(IServiceProvider, Object)を使用して、登録されているすべてのサービスを取得します。

こちらもご覧ください

適用対象

AddKeyedSingleton(IServiceCollection, Type, Object)

ソース:
ServiceCollectionServiceExtensions.Keyed.cs
ソース:
ServiceCollectionServiceExtensions.Keyed.cs
ソース:
ServiceCollectionServiceExtensions.Keyed.cs
ソース:
ServiceCollectionServiceExtensions.Keyed.cs

serviceTypeで指定された型のシングルトン サービスを、指定したIServiceCollectionに追加します。

public:
[System::Runtime::CompilerServices::Extension]
 static Microsoft::Extensions::DependencyInjection::IServiceCollection ^ AddKeyedSingleton(Microsoft::Extensions::DependencyInjection::IServiceCollection ^ services, Type ^ serviceType, System::Object ^ serviceKey);
public static Microsoft.Extensions.DependencyInjection.IServiceCollection AddKeyedSingleton(this Microsoft.Extensions.DependencyInjection.IServiceCollection services, Type serviceType, object? serviceKey);
static member AddKeyedSingleton : Microsoft.Extensions.DependencyInjection.IServiceCollection * Type * obj -> Microsoft.Extensions.DependencyInjection.IServiceCollection
<Extension()>
Public Function AddKeyedSingleton (services As IServiceCollection, serviceType As Type, serviceKey As Object) As IServiceCollection

パラメーター

services
IServiceCollection

サービスを追加する IServiceCollection

serviceType
Type

登録するサービスの種類と使用する実装。

serviceKey
Object

サービスの ServiceKey

返品

操作が完了した後のこのインスタンスへの参照。

注釈

このメソッドは、同じ型とキーのサービスが既に登録されている場合でも、常に新しい登録を IServiceCollectionに追加します。 同じ型とキーに対して複数の登録が存在する場合、 GetKeyedService<T>(IServiceProvider, Object) は最後に登録されたサービスを返します。 GetKeyedServices<T>(IServiceProvider, Object)を使用して、登録されているすべてのサービスを取得します。

こちらもご覧ください

適用対象

AddKeyedSingleton(IServiceCollection, Type, Object, Func<IServiceProvider,Object,Object>)

ソース:
ServiceCollectionServiceExtensions.Keyed.cs
ソース:
ServiceCollectionServiceExtensions.Keyed.cs
ソース:
ServiceCollectionServiceExtensions.Keyed.cs
ソース:
ServiceCollectionServiceExtensions.Keyed.cs

implementationFactoryで指定されたファクトリを使用して、serviceTypeで指定された型のシングルトン サービスを、指定したIServiceCollectionに追加します。

public:
[System::Runtime::CompilerServices::Extension]
 static Microsoft::Extensions::DependencyInjection::IServiceCollection ^ AddKeyedSingleton(Microsoft::Extensions::DependencyInjection::IServiceCollection ^ services, Type ^ serviceType, System::Object ^ serviceKey, Func<IServiceProvider ^, System::Object ^, System::Object ^> ^ implementationFactory);
public static Microsoft.Extensions.DependencyInjection.IServiceCollection AddKeyedSingleton(this Microsoft.Extensions.DependencyInjection.IServiceCollection services, Type serviceType, object? serviceKey, Func<IServiceProvider,object?,object> implementationFactory);
static member AddKeyedSingleton : Microsoft.Extensions.DependencyInjection.IServiceCollection * Type * obj * Func<IServiceProvider, obj, obj> -> Microsoft.Extensions.DependencyInjection.IServiceCollection
<Extension()>
Public Function AddKeyedSingleton (services As IServiceCollection, serviceType As Type, serviceKey As Object, implementationFactory As Func(Of IServiceProvider, Object, Object)) As IServiceCollection

パラメーター

services
IServiceCollection

サービスを追加する IServiceCollection

serviceType
Type

登録するサービスの種類。

serviceKey
Object

サービスの ServiceKey

implementationFactory
Func<IServiceProvider,Object,Object>

サービスを作成するファクトリ。

返品

操作が完了した後のこのインスタンスへの参照。

注釈

このメソッドは、同じ型とキーのサービスが既に登録されている場合でも、常に新しい登録を IServiceCollectionに追加します。 同じ型とキーに対して複数の登録が存在する場合、 GetKeyedService<T>(IServiceProvider, Object) は最後に登録されたサービスを返します。 GetKeyedServices<T>(IServiceProvider, Object)を使用して、登録されているすべてのサービスを取得します。

こちらもご覧ください

適用対象

AddKeyedSingleton<TService,TImplementation>(IServiceCollection, Object)

ソース:
ServiceCollectionServiceExtensions.Keyed.cs
ソース:
ServiceCollectionServiceExtensions.Keyed.cs
ソース:
ServiceCollectionServiceExtensions.Keyed.cs
ソース:
ServiceCollectionServiceExtensions.Keyed.cs

TImplementationで指定された実装型を持つTServiceで指定された型のシングルトン サービスを、指定したIServiceCollectionに追加します。

public:
generic <typename TService, typename TImplementation>
 where TService : class where TImplementation : class, TService[System::Runtime::CompilerServices::Extension]
 static Microsoft::Extensions::DependencyInjection::IServiceCollection ^ AddKeyedSingleton(Microsoft::Extensions::DependencyInjection::IServiceCollection ^ services, System::Object ^ serviceKey);
public static Microsoft.Extensions.DependencyInjection.IServiceCollection AddKeyedSingleton<TService,TImplementation>(this Microsoft.Extensions.DependencyInjection.IServiceCollection services, object? serviceKey) where TService : class where TImplementation : class, TService;
static member AddKeyedSingleton : Microsoft.Extensions.DependencyInjection.IServiceCollection * obj -> Microsoft.Extensions.DependencyInjection.IServiceCollection (requires 'Service : null)
<Extension()>
Public Function AddKeyedSingleton(Of TService As Class, TImplementation As Class) (services As IServiceCollection, serviceKey As Object) As IServiceCollection

型パラメーター

TService

追加するサービスの種類。

TImplementation

使用する実装の型。

パラメーター

services
IServiceCollection

サービスを追加する IServiceCollection

serviceKey
Object

サービスの ServiceKey

返品

操作が完了した後のこのインスタンスへの参照。

注釈

このメソッドは、同じ型とキーのサービスが既に登録されている場合でも、常に新しい登録を IServiceCollectionに追加します。 同じ型とキーに対して複数の登録が存在する場合、 GetKeyedService<T>(IServiceProvider, Object) は最後に登録されたサービスを返します。 GetKeyedServices<T>(IServiceProvider, Object)を使用して、登録されているすべてのサービスを取得します。

こちらもご覧ください

適用対象

AddKeyedSingleton<TService,TImplementation>(IServiceCollection, Object, Func<IServiceProvider,Object,TImplementation>)

ソース:
ServiceCollectionServiceExtensions.Keyed.cs
ソース:
ServiceCollectionServiceExtensions.Keyed.cs
ソース:
ServiceCollectionServiceExtensions.Keyed.cs
ソース:
ServiceCollectionServiceExtensions.Keyed.cs

implementationFactoryで指定されたファクトリを使用して、TImplementationで指定された実装型を持つ、TServiceで指定された型のシングルトン サービスを、指定したIServiceCollectionに追加します。

public:
generic <typename TService, typename TImplementation>
 where TService : class where TImplementation : class, TService[System::Runtime::CompilerServices::Extension]
 static Microsoft::Extensions::DependencyInjection::IServiceCollection ^ AddKeyedSingleton(Microsoft::Extensions::DependencyInjection::IServiceCollection ^ services, System::Object ^ serviceKey, Func<IServiceProvider ^, System::Object ^, TImplementation> ^ implementationFactory);
public static Microsoft.Extensions.DependencyInjection.IServiceCollection AddKeyedSingleton<TService,TImplementation>(this Microsoft.Extensions.DependencyInjection.IServiceCollection services, object? serviceKey, Func<IServiceProvider,object?,TImplementation> implementationFactory) where TService : class where TImplementation : class, TService;
static member AddKeyedSingleton : Microsoft.Extensions.DependencyInjection.IServiceCollection * obj * Func<IServiceProvider, obj, #'Service> -> Microsoft.Extensions.DependencyInjection.IServiceCollection (requires 'Service : null)
<Extension()>
Public Function AddKeyedSingleton(Of TService As Class, TImplementation As Class) (services As IServiceCollection, serviceKey As Object, implementationFactory As Func(Of IServiceProvider, Object, TImplementation)) As IServiceCollection

型パラメーター

TService

追加するサービスの種類。

TImplementation

使用する実装の型。

パラメーター

services
IServiceCollection

サービスを追加する IServiceCollection

serviceKey
Object

サービスの ServiceKey

implementationFactory
Func<IServiceProvider,Object,TImplementation>

サービスを作成するファクトリ。

返品

操作が完了した後のこのインスタンスへの参照。

注釈

このメソッドは、同じ型とキーのサービスが既に登録されている場合でも、常に新しい登録を IServiceCollectionに追加します。 同じ型とキーに対して複数の登録が存在する場合、 GetKeyedService<T>(IServiceProvider, Object) は最後に登録されたサービスを返します。 GetKeyedServices<T>(IServiceProvider, Object)を使用して、登録されているすべてのサービスを取得します。

こちらもご覧ください

適用対象

AddKeyedSingleton<TService>(IServiceCollection, Object)

ソース:
ServiceCollectionServiceExtensions.Keyed.cs
ソース:
ServiceCollectionServiceExtensions.Keyed.cs
ソース:
ServiceCollectionServiceExtensions.Keyed.cs
ソース:
ServiceCollectionServiceExtensions.Keyed.cs

TServiceで指定された型のシングルトン サービスを、指定したIServiceCollectionに追加します。

public:
generic <typename TService>
 where TService : class[System::Runtime::CompilerServices::Extension]
 static Microsoft::Extensions::DependencyInjection::IServiceCollection ^ AddKeyedSingleton(Microsoft::Extensions::DependencyInjection::IServiceCollection ^ services, System::Object ^ serviceKey);
public static Microsoft.Extensions.DependencyInjection.IServiceCollection AddKeyedSingleton<TService>(this Microsoft.Extensions.DependencyInjection.IServiceCollection services, object? serviceKey) where TService : class;
static member AddKeyedSingleton : Microsoft.Extensions.DependencyInjection.IServiceCollection * obj -> Microsoft.Extensions.DependencyInjection.IServiceCollection (requires 'Service : null)
<Extension()>
Public Function AddKeyedSingleton(Of TService As Class) (services As IServiceCollection, serviceKey As Object) As IServiceCollection

型パラメーター

TService

追加するサービスの種類。

パラメーター

services
IServiceCollection

サービスを追加する IServiceCollection

serviceKey
Object

サービスの ServiceKey

返品

操作が完了した後のこのインスタンスへの参照。

注釈

このメソッドは、同じ型とキーのサービスが既に登録されている場合でも、常に新しい登録を IServiceCollectionに追加します。 同じ型とキーに対して複数の登録が存在する場合、 GetKeyedService<T>(IServiceProvider, Object) は最後に登録されたサービスを返します。 GetKeyedServices<T>(IServiceProvider, Object)を使用して、登録されているすべてのサービスを取得します。

こちらもご覧ください

適用対象

AddKeyedSingleton<TService>(IServiceCollection, Object, Func<IServiceProvider,Object,TService>)

ソース:
ServiceCollectionServiceExtensions.Keyed.cs
ソース:
ServiceCollectionServiceExtensions.Keyed.cs
ソース:
ServiceCollectionServiceExtensions.Keyed.cs
ソース:
ServiceCollectionServiceExtensions.Keyed.cs

implementationFactoryで指定されたファクトリを使用して、TServiceで指定された型のシングルトン サービスを、指定したIServiceCollectionに追加します。

public:
generic <typename TService>
 where TService : class[System::Runtime::CompilerServices::Extension]
 static Microsoft::Extensions::DependencyInjection::IServiceCollection ^ AddKeyedSingleton(Microsoft::Extensions::DependencyInjection::IServiceCollection ^ services, System::Object ^ serviceKey, Func<IServiceProvider ^, System::Object ^, TService> ^ implementationFactory);
public static Microsoft.Extensions.DependencyInjection.IServiceCollection AddKeyedSingleton<TService>(this Microsoft.Extensions.DependencyInjection.IServiceCollection services, object? serviceKey, Func<IServiceProvider,object?,TService> implementationFactory) where TService : class;
static member AddKeyedSingleton : Microsoft.Extensions.DependencyInjection.IServiceCollection * obj * Func<IServiceProvider, obj, 'Service (requires 'Service : null)> -> Microsoft.Extensions.DependencyInjection.IServiceCollection (requires 'Service : null)
<Extension()>
Public Function AddKeyedSingleton(Of TService As Class) (services As IServiceCollection, serviceKey As Object, implementationFactory As Func(Of IServiceProvider, Object, TService)) As IServiceCollection

型パラメーター

TService

追加するサービスの種類。

パラメーター

services
IServiceCollection

サービスを追加する IServiceCollection

serviceKey
Object

サービスの ServiceKey

implementationFactory
Func<IServiceProvider,Object,TService>

サービスを作成するファクトリ。

返品

操作が完了した後のこのインスタンスへの参照。

注釈

このメソッドは、同じ型とキーのサービスが既に登録されている場合でも、常に新しい登録を IServiceCollectionに追加します。 同じ型とキーに対して複数の登録が存在する場合、 GetKeyedService<T>(IServiceProvider, Object) は最後に登録されたサービスを返します。 GetKeyedServices<T>(IServiceProvider, Object)を使用して、登録されているすべてのサービスを取得します。

こちらもご覧ください

適用対象

AddKeyedSingleton<TService>(IServiceCollection, Object, TService)

ソース:
ServiceCollectionServiceExtensions.Keyed.cs
ソース:
ServiceCollectionServiceExtensions.Keyed.cs
ソース:
ServiceCollectionServiceExtensions.Keyed.cs
ソース:
ServiceCollectionServiceExtensions.Keyed.cs

implementationInstanceで指定されたインスタンスを持つTServiceで指定された型のシングルトン サービスを、指定したIServiceCollectionに追加します。

public:
generic <typename TService>
 where TService : class[System::Runtime::CompilerServices::Extension]
 static Microsoft::Extensions::DependencyInjection::IServiceCollection ^ AddKeyedSingleton(Microsoft::Extensions::DependencyInjection::IServiceCollection ^ services, System::Object ^ serviceKey, TService implementationInstance);
public static Microsoft.Extensions.DependencyInjection.IServiceCollection AddKeyedSingleton<TService>(this Microsoft.Extensions.DependencyInjection.IServiceCollection services, object? serviceKey, TService implementationInstance) where TService : class;
static member AddKeyedSingleton : Microsoft.Extensions.DependencyInjection.IServiceCollection * obj * 'Service -> Microsoft.Extensions.DependencyInjection.IServiceCollection (requires 'Service : null)
<Extension()>
Public Function AddKeyedSingleton(Of TService As Class) (services As IServiceCollection, serviceKey As Object, implementationInstance As TService) As IServiceCollection

型パラメーター

TService

パラメーター

services
IServiceCollection

サービスを追加する IServiceCollection

serviceKey
Object

サービスの ServiceKey

implementationInstance
TService

サービスのインスタンス。

返品

操作が完了した後のこのインスタンスへの参照。

注釈

このメソッドは、同じ型とキーのサービスが既に登録されている場合でも、常に新しい登録を IServiceCollectionに追加します。 同じ型とキーに対して複数の登録が存在する場合、 GetKeyedService<T>(IServiceProvider, Object) は最後に登録されたサービスを返します。 GetKeyedServices<T>(IServiceProvider, Object)を使用して、登録されているすべてのサービスを取得します。

こちらもご覧ください

適用対象