Content
Extensibility
LightCore can be extended on two points:
- Lifecycles
- Registration Modules
Lifecycles
You will find more informationen about the existing lifecycles and the principle behind lifecycles on Lifecycles.
To create a new lifecycle, your new class have to implement the interface ILifecycle.
/// <summary>
/// Represents a lifecycle where instances can be reused.
/// </summary>
public interface ILifecycle
{
/// <summary>
/// Handle the reuse of instances.
/// </summary>
/// <param name="newInstanceResolver">The function for lazy get an instance.</param>
object ReceiveInstanceInLifecycle(Func<object> newInstanceResolver);
}
A factory for the needed dependency is passed in the method.
This factory can be called and returns that result directly. That would be the same as the TransientLifecycle from LightCore.
Registration modules
The Xml-registration of LightCore contains a RegistrationModule implementation. This implementation makes possible, to read data out of the xml file and to postprocess the data, if needed.
The abstract class for a new RegistrationModule is simple:
/// <summary>
/// Represents an abstract registration module for implementing custom registrations.
/// </summary>
public abstract class RegistrationModule
{
/// <summary>
/// Registers all candidates.
/// </summary>
/// <param name="containerBuilder">The ContainerBuilder.</param>
public abstract void Register(IContainerBuilder containerBuilder);
}
LightCore calls the Register()-method, in case of, that the module was added (registered) to LightCore.
A possible implementation of a RegistrationModule could be a extension for convention-based registration.