aboutsummaryrefslogtreecommitdiffstatsci
path: root/src
diff options
context:
space:
mode:
authorjpbruyere <jp.bruyere@hotmail.com>2016-12-16 18:46:22 +0100
committerjpbruyere <jp.bruyere@hotmail.com>2016-12-16 18:46:22 +0100
commitd7a793042bbb8f19839ef6af33b37c03788e5f80 (patch)
tree4775dd35764c4d1b1ff8f795307b8b861458585b /src
parent6bdcdb11ea37e57d9d527f47c7dab535c800bb69 (diff)
emitHandlerBinding for oot template
Diffstat (limited to 'src')
-rw-r--r--src/Instantiator.cs20
1 files changed, 14 insertions, 6 deletions
diff --git a/src/Instantiator.cs b/src/Instantiator.cs
index bfb63b81..812680e9 100644
--- a/src/Instantiator.cs
+++ b/src/Instantiator.cs
@@ -750,10 +750,19 @@ namespace Crow
}
void emitHandlerBinding (Context ctx, EventInfo sourceEvent, string expression){
- string[] bindingExp = expression.Split ('/');
+ string memberName, namedNode;
+ NodeAddress currentNode = ctx.CurrentNodeAddress, targetNA;
+
+ splitBindingExp (currentNode, expression, out targetNA, out memberName, out namedNode);
- if (bindingExp.Length == 1) {
- //datasource handler
+ string bindOnEventName = null;
+
+ if (targetNA == null)//datasource handler
+ bindOnEventName = "DataSourceChanged";
+ else if (targetNA.Count == 0)//out of tree template handler
+ bindOnEventName = "ParentChanged";
+
+ if (!string.IsNullOrEmpty(bindOnEventName)){
//we need to bind datasource method to source event
DynamicMethod dm = new DynamicMethod ("dyn_dschangedForHandler",
typeof (void),
@@ -768,7 +777,7 @@ namespace Crow
//fetch method in datasource and test if it exist
il.Emit (OpCodes.Ldarg_2);//load new datasource
il.Emit (OpCodes.Ldfld, CompilerServices.fiDSCNewDS);
- il.Emit (OpCodes.Ldstr, bindingExp[0]);//load handler method name
+ il.Emit (OpCodes.Ldstr, memberName);//load handler method name
il.Emit (OpCodes.Call, typeof(CompilerServices).GetMethod("getMethodInfoWithReflexion", BindingFlags.Static | BindingFlags.Public));
il.Emit (OpCodes.Stloc_0);//save MethodInfo
il.Emit (OpCodes.Ldloc_0);//push mi for test if null
@@ -795,8 +804,7 @@ namespace Crow
int delDSIndex = cachedDelegates.Count;
cachedDelegates.Add(dm.CreateDelegate (CompilerServices.ehTypeDSChange, this));
- ctx.emitCachedDelegateHandlerAddition(delDSIndex, typeof(GraphicObject).GetEvent("DataSourceChanged"));
- return;
+ ctx.emitCachedDelegateHandlerAddition(delDSIndex, typeof(GraphicObject).GetEvent(bindOnEventName));
}
}