Ejemplo n.º 1
0
        private string ProcessExpression(StringBuilder expressionBuffer, ViewDataContainer ViewData)
        {
            if (expressionBuffer.Length > 0)
            {
                string expression = expressionBuffer.ToString();
                expressionBuffer.Clear();

                string[] parts = expression.Split(':');
                if (!ViewData.TryGet(parts[parts.Length - 1], out string value))
                {
                    throw new Exception("A view expression referred to a key that does not exist in the view data.");
                }
                for (int i = parts.Length - 2; i >= 0; i--)
                {
                    value = PerformExpressionMethod(parts[i], value);
                }
                return(value);
            }
            else
            {
                throw new Exception("View contained an empty expression.");
            }
        }