Created
January 10, 2011 14:22
-
-
Save JeremySkinner/772816 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public interface ICommandHandler<TCommand> { | |
void Handle(TCommand command); | |
} | |
public interface IDispatcher { | |
void Invoke<TCommand>(TCommand command); | |
} | |
public class Dispatcher : IDispatcher { | |
public void Invoke<TCommand>(TCommand command) { | |
var handler = ObjectFactory.GetInstance<ICommandHandler<TCommand>>(); | |
handler.Handle(cmd); | |
} | |
} | |
public class GetUsersCommand { | |
public IList<User> Result { get; set; } | |
} | |
public class GetUsersHandler : ICommandHandler<GetUsersCommand> { | |
private ISession session; | |
public GetUsersHandler(ISession session) { | |
this.session=session; | |
} | |
public void Handle(GetUsersCommand cmd) { | |
var users = session.List<User>(); | |
cmd.Result = users; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment