diff --git a/RegistrationFactory.md b/RegistrationFactory.md index c61b7b6..064a265 100644 --- a/RegistrationFactory.md +++ b/RegistrationFactory.md @@ -1 +1,61 @@ -The `RegistrationFactory` \ No newline at end of file +The `RegistrationFactory` is a helper class to register interfaces and factories in an `IIocInstaller` and create the needed `IRegistrationBase`s. + +## Registering classes + +The way classes are registered depends on their `Lifestyle`. + +### Register `Transient` classes + +To register `Transient` classes, an `IDefaultRegistration` has to be created. The preferred way to do so is to use the generic method `Register()`: + +```c# +RegistrationFactory.Register(); +``` + +If for whatever reason you can't use this method, there is also a non generic version of it: + +```c# +RegistrationFactory.Register(typeof(IFoo), typeof(Foo)); +``` + +### Register `Singleton` classes + +To register `Singleton` classes, there has to be a `IDefaultRegistration` created as well. Similar to the registration of `Transient` classes, the preferred way to register `Singleton` classes is to use the generic method `Register()`: + +```c# +RegistrationFactory.Register(Lifestyle.Singleton); +``` + +There is again the possibility to use a non generic version of the method: + +```c# +RegistrationFactory.Register(typeof(IFoo), typeof(Foo), Lifestyle.Singleton); +``` + +### Register `Multiton` classes + +To register `Multiton` classes, an `IMultitonRegistration` has to be created. The preferred way to do so is to use the generic method `Register()`: + +```c# +RegistrationFactory.Register(); +``` + +Again there is a non generic method to use: + +```c# +RegistrationFactory.Register(typeof(IFoo), typeof(Foo), typeof(TScope)); +``` + +## Registering factories + +To register abstract factories, an `ITypedFactoryRegistration` has to be created. The preferred way to do so is to use the generic method `RegisterFactory()`: + +```c# +RegistrationFactory.RegisterFactory(container); +``` + +There is also a non generic version of the method available: + +```c# +RegistrationFactory.RegisterFactory(typeof(IFooFactory), container); +```