Пример #1
0
        private void RegisterObjectInitializerAnalyzerOnCodeBlockStart(CodeBlockStartAnalysisContext <SyntaxKind> block)
        {
            RegionsToAnalyze regionsToAnalyze = GetOrSetCachedRegionsToAnalyzeInFile(block.CodeBlock);

            var objectInitializerAnalyzer = new ObjectInitializerAnalyzer(regionsToAnalyze);

            block.RegisterSyntaxNodeAction(objectInitializerAnalyzer.AnalyzeObjectInitializers, SyntaxKind.ObjectInitializerExpression);
        }
Пример #2
0
        public override void Initialize(AnalysisContext ctx)
        {
            ctx.RegisterCodeBlockStartAction <SyntaxKind>(block =>
            {
                RegionsToAnalyze regionsToAnalyze = GetOrSetCachedRegionsToAnalyzeInFile(block.CodeBlock);

                ObjectInitializerAnalyzer objectInitializerAnalyzer = new ObjectInitializerAnalyzer(regionsToAnalyze);
                block.RegisterSyntaxNodeAction(objectInitializerAnalyzer.AnalyzeObjectInitializers,
                                               SyntaxKind.ObjectInitializerExpression);
                block.RegisterCodeBlockEndAction(objectInitializerAnalyzer.CodeBlockEndAction);
            });
        }