addKeyedSingleton<TService> method

ServiceCollection addKeyedSingleton<TService>(
  1. Object? serviceKey,
  2. KeyedImplementationFactory implementationFactory
)

Adds a keyed singleton service of the type specified in TService with a factory specified in implementationFactory to the specified ServiceCollection.

Implementation

ServiceCollection addKeyedSingleton<TService>(
  Object? serviceKey,
  KeyedImplementationFactory implementationFactory,
) {
  final descriptor = ServiceDescriptor.keyedSingleton<TService>(
    serviceKey,
    (services) => implementationFactory,
  );
  add(descriptor);
  return this;
}