From e3fbc04e878808dd67a5c06fa22cff49d6e54e61 Mon Sep 17 00:00:00 2001 From: jpbruyere Date: Mon, 12 Oct 2015 09:20:15 +0200 Subject: new binding system: DynEvents compilation --- src/CompilerServices/CompilerServices.cs | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) (limited to 'src/CompilerServices') diff --git a/src/CompilerServices/CompilerServices.cs b/src/CompilerServices/CompilerServices.cs index 44b930e0..0d13d7bf 100644 --- a/src/CompilerServices/CompilerServices.cs +++ b/src/CompilerServices/CompilerServices.cs @@ -17,14 +17,17 @@ namespace go PropertyBinding } public class Binding{ - public PropertyInfo Property; + public MemberInfo SourceMember; public string Expression; + public PropertyInfo Property { get { return SourceMember as PropertyInfo; } } + public EventInfo Event { get { return SourceMember as EventInfo; } } + public Binding(){ } - public Binding(PropertyInfo _property, string _expression) + public Binding(MemberInfo _sourceMember, string _expression) { - Property = _property; + SourceMember = _sourceMember; Expression = _expression; } } @@ -45,12 +48,15 @@ namespace go public bool FindTarget(GraphicObject source){ string member = null; + //if binding exp = '{}' => binding is done on datasource if (string.IsNullOrEmpty (Binding.Expression)) { Target = source; Member = null; return true; } + //if (Binding.SourceMember.MemberType == MemberTypes.Event) + string[] bindingExp = Binding.Expression.Split ('/'); if (bindingExp.Length == 1) { @@ -81,11 +87,14 @@ namespace go string[] bindTrg = bindingExp [ptr].Split ('.'); - if (bindTrg.Length == 2) { + if (bindTrg.Length == 1) + member = bindTrg [0]; + else if (bindTrg.Length == 2){ tmp = (tmp as GraphicObject).FindByName (bindTrg [0]); member = bindTrg [1]; } else throw new Exception ("Syntax error in binding, expected 'go dot member'"); + Target = tmp; } if (Target == null) { @@ -266,14 +275,10 @@ namespace go #endregion Type[] args = {typeof(object), handlerArgsType}; - DynamicMethod dm = new DynamicMethod("dynHandle_" + dynHandleCpt, + DynamicMethod dm = new DynamicMethod("dynHandle", typeof(void), args, srcType.Module); - - es.Source.DynamicMethodIds.Add (dynHandleCpt); - - dynHandleCpt++; #region IL generation ILGenerator il = dm.GetILGenerator(256); @@ -355,7 +360,7 @@ namespace go }else{ //search if parsing methods are present MethodInfo lopTryParseMi = lopT.GetMethod("TryParse"); - + //TODO } } -- cgit v1.3.1-4-g156e