Here’s a method delegate that I have :
delegate void ExceptionHandelr<T>(T exception,out bool handeled) where T:Exception;
I would like to have a registry of these kind of method so I could call them based on the type of their methods something like this :
var method=ErrorHandlers[typeof(NullReferenceException)];
method(exception as NullReferenceException,out handled);
How I can implement this registry? I can’t have a Dictionary<T,Method<T>> can I ?
I would create a
Dictionary<Type, Delegate>and than executed the delegate usingDynamicInvokemethod.http://msdn.microsoft.com/en-us/library/system.delegate.dynamicinvoke.aspx