private static ViewDataInfo EvalComplexExpression(object indexableObject, string expression) { foreach (ExpressionPair expressionPair in GetRightToLeftExpressions(expression)) { string subExpression = expressionPair.Left; string postExpression = expressionPair.Right; ViewDataInfo subTargetInfo = GetPropertyValue(indexableObject, subExpression); if (subTargetInfo != null) { if (String.IsNullOrEmpty(postExpression)) { return(subTargetInfo); } if (subTargetInfo.Value != null) { ViewDataInfo potential = EvalComplexExpression(subTargetInfo.Value, postExpression); if (potential != null) { return(potential); } } } } return(null); }
public static ViewDataInfo Eval(ViewDataDictionary vdd, string expression) { //Given an expression "foo.bar.baz" we look up the following (pseudocode): // this["foo.bar.baz.quux"] // this["foo.bar.baz"]["quux"] // this["foo.bar"]["baz.quux] // this["foo.bar"]["baz"]["quux"] // this["foo"]["bar.baz.quux"] // this["foo"]["bar.baz"]["quux"] // this["foo"]["bar"]["baz.quux"] // this["foo"]["bar"]["baz"]["quux"] ViewDataInfo evaluated = EvalComplexExpression(vdd, expression); return(evaluated); }
public object Eval(string expression) { ViewDataInfo info = GetViewDataInfo(expression); return((info != null) ? info.Value : null); }