コード例 #1
0
 public SubExpressionUpdate(ICalculator calculator, IFunction callFunction, string val, int propIndex, IVariable relative)
 {
     if (propIndex == -1 && callFunction is IVariableReferencePropertyUsage)
     {
         if (val != relative.Name)
         {
             // Compute dependicy properties before returning the variable
             // in order to receive correct values.
             object var = calculator.ComputeVariable(val, null);
             string[] props = ((IVariableReferencePropertyUsage)callFunction).GetDependices(var.GetType());
             if (props != null)
             {
                 foreach (string prop in props)
                 {
                     Expression exp = calculator.GetExpressionObject(val + "." + prop);
                     if (exp != null)
                         m_expressionList.Add(exp);
                 }
             }
         }
     }
     else if (propIndex > 0)
     {
         // Compute property dependices before this.
         string name = val.Substring(0, propIndex);
         if (name != relative.Name)
         {
             object var = calculator.ComputeVariable(name, null);
             if (var is IOptimizable)
             {
                 IOptimizable opt = (IOptimizable)var;
                 PropertyDependicy[] deps = opt.PropertyDependices;
                 string prop = val.Substring(propIndex + 1);
                 if (deps != null)
                 {
                     Expression[] exps = new Expression[1];
                     foreach (PropertyDependicy dep in deps)
                     {
                         if (dep.ParentProperty == prop)
                         {
                             Expression exp = calculator.GetExpressionObject(name + "." + dep.ChildProperty);
                             if (exp != null)
                                 m_expressionList.Add(exp);
                         }
                     }
                 }
             }
         }
     }
 }