Register

This function basically has two overloads these are
# Register<T>(object)
# Register<T,C>()

Register<T>(object)

Using this function you can basically register an object to a particular type. Please do note that in TinyContainer all objects gets registered as singleton objects. That means once they are created whenever you resolve them it will return the same object.

Register<T,C>()


Using this function you will be able to register a type (an interface) to another type, please do note that in type C must implement or be a subclass of type T. When you will resolve the type you will automatically be getting the object of the mapped type. That is for example if you have IButton interface which is mapped to PushButton if you use

container.Register<IButton,PushButton>();
and then use
var obj = container.Resolve<IButton>();
you will get an instance of PushButton. This would be a singleton instance and whenever resolved it will return the same instance unless you explicitly remove it from the internal cache.

Last edited Jun 22, 2011 at 10:14 PM by tikluganguly, version 2

Comments

No comments yet.