Get many instance of interface with Our.Umbraco.IoC.LightInject4 for Umbraco 7
Hi,
I need get meny objects implementing specify interface using Our.Umbraco.IoC.LightInject4, but when I try to do it using GetAllInstances() method it alwasy return me colection of one containing only the last registrated type of this interface.
I make something like this in Composition Root:
foreach (var format in TypeFinder.FindClassesOfType<IQRCodeFormat>())
{
serviceRegistry.Register(typeof(IQRCodeFormat), format, new PerRequestLifeTime());
}
serviceRegistry.Register(f => new QRCodeFormatsCollection(f.GetAllInstances<IQRCodeFormat>()), new PerRequestLifeTime());
I'd check EnableVariance option in container's options and it's set to true so LightInject should support this case.
Get many instance of interface with Our.Umbraco.IoC.LightInject4 for Umbraco 7
Hi,
I need get meny objects implementing specify interface using Our.Umbraco.IoC.LightInject4, but when I try to do it using
GetAllInstances()
method it alwasy return me colection of one containing only the last registrated type of this interface.I make something like this in Composition Root:
I'd check EnableVariance option in container's options and it's set to true so LightInject should support this case.
Maby someone know what I do wrong?
Ok, I found my mistake. I'd missing service name in
Register
method. So it should be:is working on a reply...