Share via


ImageGeneratorBuilderServiceCollectionExtensions.AddKeyedImageGenerator Method

Definition

Overloads

AddKeyedImageGenerator(IServiceCollection, Object, IImageGenerator, ServiceLifetime)

Source:
ImageGeneratorBuilderServiceCollectionExtensions.cs

Registers a keyed singleton IImageGenerator in the IServiceCollection.

public static Microsoft.Extensions.AI.ImageGeneratorBuilder AddKeyedImageGenerator(this Microsoft.Extensions.DependencyInjection.IServiceCollection serviceCollection, object? serviceKey, Microsoft.Extensions.AI.IImageGenerator innerGenerator, Microsoft.Extensions.DependencyInjection.ServiceLifetime lifetime = Microsoft.Extensions.DependencyInjection.ServiceLifetime.Singleton);
static member AddKeyedImageGenerator : Microsoft.Extensions.DependencyInjection.IServiceCollection * obj * Microsoft.Extensions.AI.IImageGenerator * Microsoft.Extensions.DependencyInjection.ServiceLifetime -> Microsoft.Extensions.AI.ImageGeneratorBuilder
<Extension()>
Public Function AddKeyedImageGenerator (serviceCollection As IServiceCollection, serviceKey As Object, innerGenerator As IImageGenerator, Optional lifetime As ServiceLifetime = Microsoft.Extensions.DependencyInjection.ServiceLifetime.Singleton) As ImageGeneratorBuilder

Parameters

serviceCollection
IServiceCollection

The IServiceCollection to which the generator should be added.

serviceKey
Object

The key with which to associate the generator.

innerGenerator
IImageGenerator

The inner IImageGenerator that represents the underlying backend.

lifetime
ServiceLifetime

The service lifetime for the generator. Defaults to Singleton.

Returns

An ImageGeneratorBuilder that can be used to build a pipeline around the inner generator.

Exceptions

serviceCollection, serviceKey, or innerGenerator is null.

Remarks

The generator is registered as a scoped service.

Applies to

AddKeyedImageGenerator(IServiceCollection, Object, Func<IServiceProvider,IImageGenerator>, ServiceLifetime)

Source:
ImageGeneratorBuilderServiceCollectionExtensions.cs

Registers a keyed singleton IImageGenerator in the IServiceCollection.

public static Microsoft.Extensions.AI.ImageGeneratorBuilder AddKeyedImageGenerator(this Microsoft.Extensions.DependencyInjection.IServiceCollection serviceCollection, object? serviceKey, Func<IServiceProvider,Microsoft.Extensions.AI.IImageGenerator> innerGeneratorFactory, Microsoft.Extensions.DependencyInjection.ServiceLifetime lifetime = Microsoft.Extensions.DependencyInjection.ServiceLifetime.Singleton);
static member AddKeyedImageGenerator : Microsoft.Extensions.DependencyInjection.IServiceCollection * obj * Func<IServiceProvider, Microsoft.Extensions.AI.IImageGenerator> * Microsoft.Extensions.DependencyInjection.ServiceLifetime -> Microsoft.Extensions.AI.ImageGeneratorBuilder
<Extension()>
Public Function AddKeyedImageGenerator (serviceCollection As IServiceCollection, serviceKey As Object, innerGeneratorFactory As Func(Of IServiceProvider, IImageGenerator), Optional lifetime As ServiceLifetime = Microsoft.Extensions.DependencyInjection.ServiceLifetime.Singleton) As ImageGeneratorBuilder

Parameters

serviceCollection
IServiceCollection

The IServiceCollection to which the generator should be added.

serviceKey
Object

The key with which to associate the generator.

innerGeneratorFactory
Func<IServiceProvider,IImageGenerator>

A callback that produces the inner IImageGenerator that represents the underlying backend.

lifetime
ServiceLifetime

The service lifetime for the generator. Defaults to Singleton.

Returns

An ImageGeneratorBuilder that can be used to build a pipeline around the inner generator.

Exceptions

serviceCollection, serviceKey, or innerGeneratorFactory is null.

Remarks

The generator is registered as a scoped service.

Applies to