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
serviceTypeThe service type to register.
factoryFunc<object>The factory function that creates the service instance.
Exceptions
- ArgumentNullException
Thrown when
factoryis null.