Example #1
0
        private VariableContext CreateVariebleContext()
        {
            VariableContext vc = MathyLanguageService.CreateVariableContext();

            foreach (SourceVariable variable in plan.Variables)
            {
                vc.Set(variable.Name, DataFuncs.CreateDefaultValue(variable.Type));
            }


            return(vc);
        }
Example #2
0
        public static VariableContext CreateVariableContext(Dictionary <string, object> variables)
        {
            VariableContext c = MathyLanguageService.CreateVariableContext();

            foreach (string variableName in variables.Keys)
            {
                c.Set(variableName, variables[variableName]);
            }


            return(c);
        }
Example #3
0
        private VariableContext CreateVariableContext()
        {
            VariableContext vc = MathyLanguageService.CreateVariableContext();

            foreach (Step step in Steps)
            {
                for (int i = 0; i <= step.InSourceVariables.Length - 1; i++)
                {
                    object value = step.InValues[i];

                    if (value != null)
                    {
                        if (value is double)
                        {
                            value = Math.Round((double)value, Settings.DecimalDigitCount);
                        }
                        else if (value is double[])
                        {
                            value = (value as double[]).Where(j => !double.IsNaN(j)).Select(j => Math.Round(j, Settings.DecimalDigitCount)).ToArray();
                        }
                        else if (value is int[])
                        {
                            value = (value as int[]).Select(j => Math.Round((double)j, Settings.DecimalDigitCount)).ToArray();
                        }
                        else if (value is Vector)
                        {
                            Vector v = (value as Vector).Clone();
                            v.SetDecimalDigitCount(Settings.DecimalDigitCount);
                            value = v;
                        }
                        else if (value is Matrix)
                        {
                            Matrix m = (value as Matrix).Clone();
                            m.SetDecimalDigitCount(Settings.DecimalDigitCount);
                            value = m;
                        }
                        vc.Set(step.InSourceVariables[i].Name, value);
                    }
                }
            }

            vc.Set("_EvaluationContext", this);
            return(vc);
        }