Table of Contents

Method RegisterLazy

Namespace
Ploch.CommandLine.Spectre.DependencyInjection
Assembly
Ploch.CommandLine.Spectre.dll

RegisterLazy(Type, Func<object>?)

Registers a factory function that will be invoked to create an instance of the service when needed. The result is a lazily created singleton: the factory runs on the first resolution and every later resolution returns the same instance.

public void RegisterLazy(Type service, Func<object>? factory)

Parameters

service Type

The service type to register.

factory Func<object>

The factory function that creates the service instance.

Exceptions

ArgumentNullException

Thrown when factory is null.