private object SetPath(IDictionary<string, object> variables, string path, object value, Engine engine)
 {
     CodeTreeHelper.Print(new CodeTree().Compile(engine, CodeType.Set, path));
     var result = engine.SetPath(path, null, value);
     foreach (var name in variables.Keys) variables[name] = engine.GetVariable(name);
     return result;
 }
예제 #2
0
 protected override object OnGet(Engine engine)
 {
     if (Path != null && CodeTree.Compile(engine, CodeType.Get, Path).IsSetOrIncrement)
         return CodeTree.Get(engine);
     var value = engine.Get(ValueProperty, ValuePath, ValueCodeTree);
     if (Var != null)
     {
         var variable = engine.GetVariable(Var, VarCodeTree);
         if (Op != AssignmentOp.Assign)
         {
             var oldValue = engine.GetVariable(variable);
             value = engine.Operator(Op, oldValue, value);
         }
         engine.DefineVariableInParentScope(variable, value);
         return value;
     }
     if (IsBareTarget)
     {
         var target = engine.Get(TargetProperty);
         target = engine.Operator(Op, target, value);
         Target = value;
         return value;
     }
     var context = engine.Context;
     var type = engine.GetType(TypeProperty, TypePath, TypeCodeTree);
     if (Op != AssignmentOp.Assign)
     {
         object oldValue = null;
         if (DependencyProperty != null)
             oldValue = PathHelper.GetDependencyProperty(engine, context as DependencyObject, DependencyProperty);
         else if (PropertyName != null)
             oldValue = PathHelper.GetProperty(engine, context, PropertyName);
         else if (FieldName != null)
             oldValue = PathHelper.GetField(engine, context, FieldName);
         else if (StaticPropertyName != null)
             oldValue = PathHelper.GetStaticProperty(engine, type, StaticPropertyName);
         else if (StaticFieldName != null)
             oldValue = PathHelper.GetStaticField(engine, type, StaticFieldName);
         else if (Path != null)
             oldValue = engine.GetPath(Path, CodeTree);
         else
             oldValue = context;
         value = engine.Operator(Op, oldValue, value);
     }
     if (DependencyProperty != null)
         PathHelper.SetDependencyProperty(engine, context as DependencyObject, DependencyProperty, value);
     else if (PropertyName != null)
         PathHelper.SetProperty(engine, context, PropertyName, value);
     else if (FieldName != null)
         PathHelper.SetField(engine, context, FieldName, value);
     else if (StaticPropertyName != null)
         PathHelper.SetStaticProperty(engine, type, StaticPropertyName, value);
     else if (StaticFieldName != null)
         PathHelper.SetStaticField(engine, type, StaticFieldName, value);
     else if (Path != null)
         engine.SetPath(Path, SetCodeTree, value);
     else
         Context = value;
     return value;
 }