Created
February 9, 2012 16:26
-
-
Save ashic/1780910 to your computer and use it in GitHub Desktop.
Behold...my 4 line "framework"
This file contains hidden or 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 class Bus | |
{ | |
public Dictionary<Type, Action<object>> _handlers = new (); | |
public void Register<T>(Action<T> handler) { _handlers[typeof(T)] = x=> (T)handler; } | |
public void Handle(object message) { _handlers[message.GetType()](message); } | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment