Skip to content

IServiceLocator.GetLazyService() method

Defined in

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

Applies to

net10.0, net10.0-browserwasm1.0, net10.0-desktop1.0, net9.0, net9.0-browserwasm1.0, net9.0-desktop1.0, net8.0, net8.0-ios17.5, net8.0-maccatalyst17.5, net8.0-macos14.2, net8.0-macos14.5, net8.0-tvos17.2, netstandard2.1, net462, net481, net471

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 -- A Lazy that provides access to the requested service instance. The service is created when the Value 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
contractstringThe contract name that identifies the service to retrieve. Cannot be null.

Returns: Lazy -- A Lazy instance that provides access to the requested service. The service is created when the Value property is first accessed.