Skip to content

Instantly share code, notes, and snippets.

@JeremySkinner
Created October 15, 2009 12:17
Show Gist options
  • Save JeremySkinner/210920 to your computer and use it in GitHub Desktop.
Save JeremySkinner/210920 to your computer and use it in GitHub Desktop.
var handlerInterface = typeof(MyHandler).GetInterfaces()[0]; //This implements IHandle<T> (eg IHandle<Foo>)
var commandType = handlerInterface.GetGenericArguments()[0]; //this is the type being handled, eg Foo
var maker = GetType().GetMethod("ResolveHandler", BindingFlags.Static | BindingFlags.Public | BindingFlags.Instance);
var compiledDelegate = (Func<object>)Delegate.CreateDelegate(typeof(Func<object>), maker);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment