public void EvaluateFunctions() { foreach (string function in Functions) { _result = _evaluator.Evaluate(function); Assert.IsNotNull(_result); } }
/// <summary> /// Evaluates the formulas. /// </summary> private void EvaluateFormulas() { SPSEvaluator evaluator = new SPSEvaluator(); // Evaluate all foreach (SPSKeyValuePair keyValue in _parameterFormulas) { Debug.WriteLine("1-CAML Original - " + keyValue.Key + " " + keyValue.Value); keyValue.Value = evaluator.Evaluate(keyValue.Value); Debug.WriteLine("2-CAML Evaluated - " + keyValue.Key + " " + keyValue.Value); } }
public string Evaluate(string value) { SPSEvaluator evaluator = new SPSEvaluator(); string result = string.Empty; try { result = evaluator.Evaluate(value); } catch (SPSEvaluatorException ex) { DumpException("Evaluator", ex); } return(result); }
/// <summary> /// Evaluates the parameters. /// 1.- Process _variableFunctions list evaluating each function /// 2.- Process _variableFunctions list replacing the evaluated /// formula with a value thats come from _variableValues list /// </summary> private void EvaluateParameters() { SPSEvaluator evaluator = new SPSEvaluator(); // Evaluate all foreach (SPSKeyValuePair keyValue in _variableFunctions) { Debug.WriteLine("1-CAML Original - " + keyValue.Key + " " + keyValue.Value); keyValue.Value = evaluator.Evaluate(keyValue.Value); Debug.WriteLine("2-CAML Evaluated - " + keyValue.Key + " " + keyValue.Value); } // Replace with Consumer foreach (SPSKeyValuePair keyValue in _variableValues) { Debug.WriteLine("3-CAML Provider - " + keyValue.Key + " " + keyValue.Value); _variableFunctions.ReplaceValue(keyValue.Key, keyValue.Value); } }
/// <summary> /// Test the evaluator /// </summary> /// <returns>An string with samples</returns> private static string EvaluatorSample() { StringBuilder stringBuilder = new StringBuilder(); string[] functions = new[] { "DateNow()", "DateTimeNow()", "MonthNumber()", "DayNumber()", "YearNumber()", "Guid()", "UserLogin()", "UserName()", "UserId()", "UserEmail()", "WebName()", "WebTitle()", "WebUrl()", "Empty()", "DateFormat('d')", "DateFormat('s')", "DateFormat('T')", "DateCalcFormat('s',M+1)", "DateCalcFormat('T',D+1)", "DateCalcFormat('d',Y-1)", "QueryString('Test')" }; SPSEvaluator evaluator = new SPSEvaluator(); stringBuilder.Append("<table width='100%' border='0'>"); foreach (string function in functions) { stringBuilder.AppendFormat("<tr><td width=50%><font color=blue>{0}</font></td><Td>{1}</td></tr>", function, evaluator.Evaluate(function)); } stringBuilder.Append("</table>"); return(stringBuilder.ToString()); }