Retrieving registered types from Unity container

The Unity container exposes the Registrations property which returns an IEnumerable list of the registrations.

More details…

Advertisements

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>();