-
Notifications
You must be signed in to change notification settings - Fork 2
IRegistrationBase
The IRegistrationBase
is a base interface for all registration classes that are used to register interfaces with the IocContainer
.
It consists only of two properties:
/// <summary>
/// The name of the <see cref="IRegistrationBase"/>
/// </summary>
string Name { get; }
and
/// <summary>
/// The <see cref="Type"/> of the Interface that is registered with this <see cref="IRegistrationBase"/>
/// </summary>
Type InterfaceType { get; }
All of the following implementations of the IRegistrationBase
can be easily created by the RegistrationFactory
.
This is the default registration that is used to register a Type
for the interface it implements. TInterface
is the Type
of the interface.
In addition to the implemented properties from the IRegistrationBase
the IDefaultRegistration
adds the following properties and methods:
-
The Type that implements the
IRegistrationBase.InterfaceType
that gets registeredType ImplementationType { get; }
-
The
Lifestyle
of the registeredType
Lifestyle Lifestyle { get; }
-
An
Action
that is invoked when an instance of the registered type is createdAction<TInterface> OnCreateAction { get; }
-
A method to pass the
OnCreateAction
to theIDefaultRegistration
IDefaultRegistration<TInterface> OnCreate(Action<TInterface> action);
The IMultitonRegistration
is derived from the IDefaultRegistration
and is used to register a Type
that is of the Lifestyle.Multiton
.
It adds only one property to the already overridden ones, the Type
of the multiton scope:
Type Scope { get; }
The ITypedFactoryRegistration
is used to register an abstract typed factory with the IocContainer
. TFactory
is the Type
of the factory.
It consists of the implemented properties from the IRegistrationBase
and adds one property of its own, the class that contains the implemented abstract factory of this ITypedFactoryRegistration
:
ITypedFactory<TFactory> Factory { get; }
The TypedFactoryRegistration<TFactory>
class implements the ITypedFactoryRegistration<TFactory>
interface and also handles the implementation of the abstract factories. Therefore it supplies the CreateFactory()
method:
private void CreateFactory(IIocContainer container)
{
}
This is done by writing the IL code for the Create()
methods manually that call the IocContainer.Resolve()
method, as well as the ClearMultitonInstance
method that calls the IocContainer.ClearMultitonInstances<>()
method.
The IUnitTestCallbackRegistration
is a special IRegistrationBase
that allows to set a ResolveCallback<TInterface>
as a callback that is called on IIocContainer.Resolve<T>
. This can be useful if you for whatever reason need some special handling for unit tests.
The ResolveCallback<TInterface>
looks like this:
public delegate TInterface ResolveCallback<out TInterface>(params object[] parameters);
Still questions or problems?
Create a new Issue.
- Home
- Install Lightweight IOC Container
- Usage
- Advanced usage
- Detailed documentation