Open daveraine opened 4 years ago
Hi @daveraine
I apologize I usually get back to people quicker but some how I missed this issue. This should work and does for Func<IMultipleService>
but apparently fails for a custom delegate.
What's failing is the auto registration of the MultipleServiceDelegate
delegate. You can get around this by explicitly registering it.
container.Configure(c =>
{
c.Export<MultipleService1>().As<IMultipleService>().WithMetadata("IntValue", 1);
c.Export<MultipleService2>().As<IMultipleService>().WithMetadata("IntValue", 2);
c.Export<MultipleService3>().As<IMultipleService>().WithMetadata("IntValue", 3);
c.Export<MultipleService4>().As<IMultipleService>().WithMetadata("IntValue", 4);
c.Export<MultipleService5>().As<IMultipleService>().WithMetadata("IntValue", 5);
c.AddActivationStrategy(new DelegateNoArgWrapperStrategy(typeof(MultipleServiceDelegate), c.OwningScope));
});
Awesome, thanks for the info. No worries about the late reply. I actually refactored my code to use keyed registrations and extra data to achieve what I wanted and I think that is a better solution for me in the end, but good to hear there is a workaround currently if I do need this behaviour.
I'm trying to resolve multiple services with metadata using a delegate factory but seems this is not supported. I've modified the
LazyMetadata_StronglyTyped
test to illustrate what I'm trying to achieve.Is this something that could be supported?