dryioc

Resolve one of multiple registrations with DryIoc

女生的网名这么多〃 提交于 2019-12-06 04:45:49
Given the small example below, is there a way to mark (attribute, name convention,... ) the MyInterface argument in MyService2 , so that it will resolve correctly, or is the only way to pass in MyInterface[] ? I know that Castle Windsor can resolve it based on naming convention, but I haven't found something similar in DryIoc public interface MyInterface { } public class MyImplementationA : MyInterface { } public class MyImplementationB : MyInterface { } public class MyService1 { public MyService1(MyInterface[] implementations) { Console.WriteLine(implementations.GetType().Name); } } public

DryIOC Event Aggregator

余生长醉 提交于 2019-12-04 11:43:18
I'm trying to Implement an event aggregator using DryIOC. I have an Event dispatcher as follows: public class DryIocEventDispatcher : IEventDispatcher { private readonly IContainer _container; public DryIocEventDispatcher(IContainer container) { _container = container; } public void Dispatch<TEvent>(TEvent eventToDispatch) where TEvent : EventArgs { foreach (var handler in _container.ResolveMany<IHandles<TEvent>>()) { handler.Handle(eventToDispatch); } } } I have a number of classes that can handle events. Indicated by the following Interface: public interface IHandles<T> where T : System