APISampleUnitTestsCS.FAQ.ClassRenamer.VisitConstructorDeclaration C# (CSharp) Méthode

VisitConstructorDeclaration() public méthode

public VisitConstructorDeclaration ( ConstructorDeclarationSyntax node ) : SyntaxNode
node ConstructorDeclarationSyntax
Résultat SyntaxNode
            public override SyntaxNode VisitConstructorDeclaration(ConstructorDeclarationSyntax node)
            {
                var updatedConstructorDeclaration = (ConstructorDeclarationSyntax)base.VisitConstructorDeclaration(node);

                // Get TypeSymbol corresponding to the containing ClassDeclarationSyntax for the
                // ConstructorDeclarationSyntax and check whether it is the same as the TypeSymbol
                // we are searching for.
                var classSymbol = (TypeSymbol)SemanticModel.GetDeclaredSymbol(node).ContainingSymbol;
                if (classSymbol.Equals(SearchSymbol))
                {
                    // Replace the identifier token containing the name of the class.
                    SyntaxToken updatedIdentifierToken =
                        Syntax.Identifier(
                            updatedConstructorDeclaration.Identifier.LeadingTrivia,
                            NewName,
                            updatedConstructorDeclaration.Identifier.TrailingTrivia);

                    updatedConstructorDeclaration = updatedConstructorDeclaration.WithIdentifier(updatedIdentifierToken);
                }

                return updatedConstructorDeclaration;
            }