I have multiple implementations of this interface:
public interface IDomainEventHandler<TDomainEventContext>
where TDomainEventContext : IDomainEventContext
{
void Handle(TDomainEventContext context, object sender);
}
and I want to resolve some of them on run time according to the type of the event context, so i added typed factory to my system:
ublic interface IDomainEventHandlerFactory : IDisposable
{
IEnumerable<IDomainEventHandler<TDomainEventContext>> ResolveAll<TDomainEventContext>()
where TDomainEventContext : IDomainEventContext;
}
and this is my registration:
container.Register(Classes.FromAssemblyContaining<SomeClass>().
BasedOn(typeof(IDomainEventHandler<>)).WithServiceAllInterfaces().
LifestyleTransient());
Now I want to do the next thing:
adding Name property to the IDomainEventHandler interface :
public interface IDomainEventHandler<TDomainEventContext>
where TDomainEventContext : IDomainEventContext
{
string Name { get; }
void Handle(TDomainEventContext context, object sender);
}
Then I want to register each event handler with this Name property (by convention), and then I want to be able to resolve all the components with the same name (and the same type of event context)
I hope my goal is clear enough
so my questions are:
1) how am i doing the registration part (against the Name field in my interface)?
2) is it possible for two event handlers to register with the same name?
3) how the factory should looks like?
again my goal is to be able to say: i want all the event handlers handling event context of type "AddingItemEventContext" but only those with name "ElectronicItem" (and then i get all the handlers that relevant to me)