Пример #1
0
            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);
            }
Пример #2
0
            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);
            }
Пример #3
0
        public object Eval(string expression)
        {
            ViewDataInfo info = GetViewDataInfo(expression);

            return((info != null) ? info.Value : null);
        }