I have the following interfaces and classes.
interface ICommand { ... }
class Command1 : ICommand { ... }
class Command1 : ICommand { ... }
interface IHandle<TCommand> where TCommand : ICommand
{
IResult Handle(TCommand command);
}
Command1Handler : IHandle<Command1> { ... }
Command2Handler : IHandle<Command2> { ... }
Command1Handler and Command2Handler are registered in a Castle Widsor container. When I receive a command I would like to find the Handler in the container that can handle the command.
public IResult ProcessCommand(ICommand command)
{
var handler = Container.Resolve //How to resolve based on command?
return handler.Handle(command);
}
Aucun commentaire:
Enregistrer un commentaire