public static void InvokeSafely(this NPEventHandler.CustomEventHandler ev) { if (ev == null) { return; } string eventName = ev.GetType().FullName; foreach (NPEventHandler.CustomEventHandler handler in ev.GetInvocationList()) { try { handler(); } catch (Exception ex) { LogException(ex, handler.Method.Name, handler.Method.ReflectedType?.FullName, eventName); } } }
public static void InvokeSafely <T>(this NPEventHandler.CustomEventHandler <T> ev, T arg) where T : EventArgs { if (ev == null) { return; } var eventName = ev.GetType().FullName; foreach (NPEventHandler.CustomEventHandler <T> handler in ev.GetInvocationList()) { try { handler(arg); } catch (Exception ex) { LogException(ex, handler.Method.Name, handler.Method.ReflectedType.FullName, eventName); } } }