aboutsummaryrefslogtreecommitdiffstatsci
path: root/src/CompilerServices
diff options
context:
space:
mode:
authorjpbruyere <jp.bruyere@hotmail.com>2016-12-23 11:08:25 +0100
committerjpbruyere <jp.bruyere@hotmail.com>2016-12-23 12:46:00 +0100
commitdecb4506152e9acd51200a9fb99076eaa4a78f63 (patch)
treed8c823d92ec8807d594c74b8d1b017b9e464907d /src/CompilerServices
parent88ddb3a0896f3f5639ddd5eb7edc6133874b913f (diff)
Remove old datasource handler if not null
Diffstat (limited to 'src/CompilerServices')
-rw-r--r--src/CompilerServices/CompilerServices.cs17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/CompilerServices/CompilerServices.cs b/src/CompilerServices/CompilerServices.cs
index 7dcfd972..38d4590c 100644
--- a/src/CompilerServices/CompilerServices.cs
+++ b/src/CompilerServices/CompilerServices.cs
@@ -802,6 +802,23 @@ namespace Crow
}
return null;
}
+ /// <summary>
+ /// Removes delegate from event handler by name
+ /// </summary>
+ public static void RemoveEventHandler(object instance, string eventName, string delegateName){
+ Type t = instance.GetType ();
+ FieldInfo fiEvt = CompilerServices.GetEventHandlerField (t, eventName);
+ EventInfo eiEvt = t.GetEvent (eventName);
+ MulticastDelegate multiDel = fiEvt.GetValue (instance) as MulticastDelegate;
+ if (multiDel != null) {
+ foreach (Delegate d in multiDel.GetInvocationList()) {
+ if (d.Method.Name == delegateName) {
+ eiEvt.RemoveEventHandler (instance, d);
+ Debug.WriteLine ("event handler removed: " + delegateName + " in " + t.FullName);
+ }
+ }
+ }
+ }
}
}