Unity Container overview

Create container

IUnityContainer container = new UnityContainer();

Register type

container.RegisterType<ILogService>();

Create more than one registration using the same registered type

container.RegisterType<ILogService>("Log");

Register an existing instance

ILogService logService = new LogService();
container.RegisterInstance<ILogService>(logService);

Retrieve an object from the container

ILogService logService = container.Resolve<ILogService>();
Advertisements