Example #1
0
        private static int AnalyzeForEachSyntax(ForEachStatementSyntax forEachSyntax, int nesting)
        {
            int score = 1;

            score += forEachSyntax.Expression.DescendantNodes().Where(t => t is InvocationExpressionSyntax).Count();
            var a      = forEachSyntax.Expression.DescendantNodes();
            var nested = forEachSyntax.DescendantNodes().OfType <StatementSyntax>();

            score += AnalyzeStatements(new SyntaxList <StatementSyntax>(nested), nesting + 1);

            return(score);
        }
Example #2
0
        public void VisitForEachStatement(ForEachStatementSyntax node)
        {
            DatabaseAccessingForeachLoopDeclaration <LINQToSQL> dbAccessingForEach =
                (from n in node.DescendantNodes().OfType <IdentifierNameSyntax>()
                 from v in _databaseQueryVariables.Keys
                 where n.Identifier.Text == v.DescendantNodes().OfType <VariableDeclaratorSyntax>().First().Identifier.Text
                 select new DatabaseAccessingForeachLoopDeclaration <LINQToSQL>()).FirstOrDefault();

            if (dbAccessingForEach != null)
            {
                DatabaseAccessingLoopDeclarations.Add(dbAccessingForEach);
            }
            else
            {
                LoopDeclarations.Add(new ForEachLoopDeclaration());
            }
        }