Skip to content

Instantly share code, notes, and snippets.

@ashic
Created February 9, 2012 16:26
Show Gist options
  • Save ashic/1780910 to your computer and use it in GitHub Desktop.
Save ashic/1780910 to your computer and use it in GitHub Desktop.
Behold...my 4 line "framework"
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