Esempio n. 1
0
        /// <summary>
        /// Processes the given expression.
        /// </summary>
        /// <param name="expression">The expression to process.</param>
        /// <param name="element">The parent element.</param>
        /// <param name="validPrefixes">The list of acceptable Hungarian-type prefixes.</param>
        private void ProcessExpression(Expression expression, Element element, Dictionary <string, string> validPrefixes)
        {
            Param.AssertNotNull(expression, "expression");
            Param.AssertNotNull(element, "element");
            Param.AssertNotNull(validPrefixes, "validPrefixes");

            // Check the type of the expression.
            if (expression.ExpressionType == ExpressionType.AnonymousMethod)
            {
                AnonymousMethodExpression anonymousMethod = (AnonymousMethodExpression)expression;

                // Check the anonymous method's variables.
                VariableCollection variables = anonymousMethod.Variables;
                if (variables != null)
                {
                    foreach (IVariable variable in variables)
                    {
                        this.CheckMethodVariablePrefix(variable, element, validPrefixes);
                    }

                    // Check the statements under the anonymous method.
                    if (anonymousMethod.Children.StatementCount > 0)
                    {
                        for (Statement statement = anonymousMethod.FindFirstChildStatement(); statement != null; statement = statement.FindNextSiblingStatement())
                        {
                            this.ProcessStatement(statement, element, validPrefixes);
                        }
                    }
                }
            }

            // Check the child expressions under this expression.
            if (expression.Children.StatementCount > 0)
            {
                for (Expression childExpression = expression.FindFirstChildExpression(); childExpression != null; childExpression = childExpression.FindNextSiblingExpression())
                {
                    this.ProcessExpression(childExpression, element, validPrefixes);
                }
            }
        }