Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
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.
Maby someone know what I do wrong?
Ok, I found my mistake. I'd missing service name in Register method. So it should be:
serviceRegistry.Register(typeof(IQRCodeFormat), format, format.Name, new PerRequestLifeTime());
is working on a reply...
Write your reply to:
Image will be uploaded when post is submitted