ImageGeneratorExtensions.GetRequiredService Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Overloads
GetRequiredService(IImageGenerator, Type, Object) |
Asks the IImageGenerator for an object of the specified type |
GetRequiredService<TService>(IImageGenerator, Object) |
Asks the IImageGenerator for an object of type |
GetRequiredService(IImageGenerator, Type, Object)
- Source:
- ImageGeneratorExtensions.cs
Asks the IImageGenerator for an object of the specified type serviceType
and throws an exception if one isn't available.
public static object GetRequiredService(this Microsoft.Extensions.AI.IImageGenerator generator, Type serviceType, object? serviceKey = default);
static member GetRequiredService : Microsoft.Extensions.AI.IImageGenerator * Type * obj -> obj
<Extension()>
Public Function GetRequiredService (generator As IImageGenerator, serviceType As Type, Optional serviceKey As Object = Nothing) As Object
Parameters
- generator
- IImageGenerator
The generator.
- serviceType
- Type
The type of object being requested.
- serviceKey
- Object
An optional key that can be used to help identify the target service.
Returns
The found object.
Exceptions
serviceType
is null
.
No service of the requested type for the specified key is available.
Remarks
The purpose of this method is to allow for the retrieval of services that are required to be provided by the IImageGenerator, including itself or any services it might be wrapping.
Applies to
GetRequiredService<TService>(IImageGenerator, Object)
- Source:
- ImageGeneratorExtensions.cs
Asks the IImageGenerator for an object of type TService
and throws an exception if one isn't available.
public static TService GetRequiredService<TService>(this Microsoft.Extensions.AI.IImageGenerator generator, object? serviceKey = default);
static member GetRequiredService : Microsoft.Extensions.AI.IImageGenerator * obj -> 'Service
<Extension()>
Public Function GetRequiredService(Of TService) (generator As IImageGenerator, Optional serviceKey As Object = Nothing) As TService
Type Parameters
- TService
The type of the object to be retrieved.
Parameters
- generator
- IImageGenerator
The generator.
- serviceKey
- Object
An optional key that can be used to help identify the target service.
Returns
The found object.
Exceptions
generator
is null
.
No service of the requested type for the specified key is available.
Remarks
The purpose of this method is to allow for the retrieval of strongly typed services that are required to be provided by the IImageGenerator, including itself or any services it might be wrapping.