Register Factory
VContainer allows to register a Func<> delegate for the creation of an instance. This is especially useful in scenarios where instance is created at any time during execution, or multiple instances are created at any time.
By registering Factory instead of instance, you can keep the dependency static and simple.
Register Func<> Factory that requires only runtime parameters#
We can resolve like below:
Register Func<> Factory that requires container dependencies and runtime parameters#
This method required 2 params
Func<>: Receives Container and returns Factory.Lifetime: Determines how often the Factory is generated. (that is, how often the outer Func is executed.)
We can resolve like below: