Ejemplo n.º 1
0
 private object[] getParameterValues(MethodInfo mif)
 {
     if (_variables == null)
     {
         createInputs();
     }
     if (_variables.Count > 0)
     {
         VariableList    vars = _root.InputVariables;
         ParameterInfo[] pifs = mif.GetParameters();
         int             n    = 0;
         if (pifs != null)
         {
             n = pifs.Length;
         }
         if (n != _variables.Count)
         {
             throw new MathException("Parameter count mismatch [{0}] != [{1}]", _variables.Count, n);
         }
         Form f = this.FindForm();
         if (f != null)
         {
             object[] vs = new object[_variables.Count];
             foreach (MathPropertyPointer mpp in _variables.Values)
             {
                 mpp.Top.GetInstance(f);
             }
             for (int i = 0; i < vs.Length; i++)
             {
                 string sv = vars.GetKeyByCodeVariableName(pifs[i].Name);
                 if (_variables.ContainsKey(sv))
                 {
                     vs[i] = _variables[sv].Bottom.Instance;
                     if (vs[i] == null)
                     {
                         vs[i] = VPL.VPLUtil.GetDefaultValue(pifs[i].ParameterType);
                     }
                     else
                     {
                         Type t = vs[i].GetType();
                         if (!pifs[i].ParameterType.IsAssignableFrom(t))
                         {
                             bool bt;
                             vs[i] = VPL.VPLUtil.ConvertObject(vs[i], pifs[i].ParameterType, out bt);
                             if (!bt)
                             {
                             }
                         }
                     }
                 }
                 else
                 {
                     throw new MathException("Method parameter [{0}] not found", pifs[i].Name);
                 }
             }
             return(vs);
         }
     }
     return(new object[] { });
 }