public string EvaluateFormula_Base(string formula, BaseClasses.Data.BaseRecord dataSourceForEvaluate, string format, System.Collections.Generic.IDictionary <string, object> variables, bool includeDS) { FormulaEvaluator e = new FormulaEvaluator(); // add variables for formula evaluation if (variables != null) { System.Collections.Generic.IEnumerator <System.Collections.Generic.KeyValuePair <string, object> > enumerator = variables.GetEnumerator(); while (enumerator.MoveNext()) { e.Variables.Add(enumerator.Current.Key, enumerator.Current.Value); } } if (includeDS) { } e.CallingControl = this; // All variables referred to in the formula are expected to be // properties of the DataSource. For example, referring to // UnitPrice as a variable will refer to DataSource.UnitPrice e.DataSource = dataSourceForEvaluate; // Define the calling control. e.CallingControl = this; object resultObj = e.Evaluate(formula); if (resultObj == null) { return(""); } if (!string.IsNullOrEmpty(format) && (string.IsNullOrEmpty(formula) || formula.IndexOf("Format(") < 0)) { return(FormulaUtils.Format(resultObj, format)); } else { return(resultObj.ToString()); } }