Basic Registration API

Overview
The basic registration API is a quick api designed to form the most basic of IoC tasks in single line operations.

Simple type registration
Simple type registration can be achieved using the typed generic Register() method.

            IContainerManager containerManager = new ContainerManager();
            containerManager.Adapter.Register<IDependantClass, DependantClass>();

Multiple types
Registration of components against multiple types can be achieved by simply calling the register method twice.

            IContainerManager containerManager = new ContainerManager();
            containerManager.Adapter.Register<IDependantClass, DependantClass>();
            containerManager.Adapter.Register<ISuperDependantClass, DependantClass>();

Named
Named registrations can be achieved by using the Register() method overload with a string ‘name’ parameter specified.

            IContainerManager containerManager = new ContainerManager();
            containerManager.Adapter.Register<IDependantClass>("Dependency Name");

Instance

Instance registrations can be achieved by using the Register() method overload with an ‘instance’ parameter specified.

            IContainerManager containerManager = new ContainerManager();
            DependantClass instance = new DependantClass();
            containerManager.Adapter.Register<IDependantClass>(instance);
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s