Skip to content

IServiceLocator.GetLazyService() method

Defined in

Type: IServiceLocator Namespace: Splat Assembly: Splat.Core.dll

Applies to

net11.0, net10.0, net47, net471, net472, net48, net481

Overloads

  1. Lazy<T> GetLazyService<T>()

  2. Lazy<T> GetLazyService<T>(string contract)

1. Overload

Lazy<T> GetLazyService<T>()

Summary: Retrieves a lazily initialized instance of the specified service type from the dependency injection container.

Type parameters

NameDescription
TThe type of the service to retrieve. Must have a public parameterless constructor.

Returns: Lazy (opens in a new tab) -- A Lazy (opens in a new tab) that provides access to the requested service instance. The service is created when the Value (opens in a new tab) property is first accessed.

2. Overload

Lazy<T> GetLazyService<T>(string contract)

Summary: Retrieves a lazily initialized service of the specified type associated with the given contract name.

Type parameters

NameDescription
TThe type of the service to retrieve. Must have a public parameterless constructor.

Parameters

NameTypeDescription
contractstring (opens in a new tab)The contract name that identifies the service to retrieve. Cannot be null.

Returns: Lazy (opens in a new tab) -- A Lazy (opens in a new tab) instance that provides access to the requested service. The service is created when the Value (opens in a new tab) property is first accessed.