Пример #1
0
        protected override TDeclarationNode AddNamedType <TDeclarationNode>(TDeclarationNode destination, INamedTypeSymbol namedType, CodeGenerationOptions options, IList <bool> availableIndices, CancellationToken cancellationToken)
        {
            CheckDeclarationNode <TypeDeclarationSyntax, NamespaceDeclarationSyntax, CompilationUnitSyntax>(destination);

            if (destination is TypeDeclarationSyntax)
            {
                return(Cast <TDeclarationNode>(NamedTypeGenerator.AddNamedTypeTo(this, Cast <TypeDeclarationSyntax>(destination), namedType, options, availableIndices, cancellationToken)));
            }
            else if (destination is NamespaceDeclarationSyntax)
            {
                return(Cast <TDeclarationNode>(NamedTypeGenerator.AddNamedTypeTo(this, Cast <NamespaceDeclarationSyntax>(destination), namedType, options, availableIndices, cancellationToken)));
            }
            else
            {
                return(Cast <TDeclarationNode>(NamedTypeGenerator.AddNamedTypeTo(this, Cast <CompilationUnitSyntax>(destination), namedType, options, availableIndices, cancellationToken)));
            }
        }
Пример #2
0
        public override TDeclarationNode UpdateDeclarationMembers <TDeclarationNode>(TDeclarationNode declaration, IList <ISymbol> newMembers, CodeGenerationOptions options = null, CancellationToken cancellationToken = default)
        {
            if (declaration is MemberDeclarationSyntax memberDeclaration)
            {
                return(Cast <TDeclarationNode>(NamedTypeGenerator.UpdateNamedTypeDeclaration(this, memberDeclaration, newMembers, options, cancellationToken)));
            }

            if (declaration is CSharpSyntaxNode syntaxNode)
            {
                switch (syntaxNode.Kind())
                {
                case SyntaxKind.CompilationUnit:
                case SyntaxKind.NamespaceDeclaration:
                    return(Cast <TDeclarationNode>(NamespaceGenerator.UpdateCompilationUnitOrNamespaceDeclaration(this, syntaxNode, newMembers, options, cancellationToken)));
                }
            }

            return(declaration);
        }
Пример #3
0
        protected override TDeclarationNode AddNamedType <TDeclarationNode>(TDeclarationNode destination, INamedTypeSymbol namedType, CSharpCodeGenerationContextInfo info, IList <bool>?availableIndices, CancellationToken cancellationToken)
        {
            CheckDeclarationNode <TypeDeclarationSyntax, BaseNamespaceDeclarationSyntax, CompilationUnitSyntax>(destination);

            var csharpInfo = info;

            if (destination is TypeDeclarationSyntax typeDeclaration)
            {
                return(Cast <TDeclarationNode>(NamedTypeGenerator.AddNamedTypeTo(this, typeDeclaration, namedType, csharpInfo, availableIndices, cancellationToken)));
            }
            else if (destination is BaseNamespaceDeclarationSyntax namespaceDeclaration)
            {
                return(Cast <TDeclarationNode>(NamedTypeGenerator.AddNamedTypeTo(this, namespaceDeclaration, namedType, csharpInfo, availableIndices, cancellationToken)));
            }
            else
            {
                return(Cast <TDeclarationNode>(NamedTypeGenerator.AddNamedTypeTo(this, Cast <CompilationUnitSyntax>(destination), namedType, csharpInfo, availableIndices, cancellationToken)));
            }
        }
Пример #4
0
 public override SyntaxNode CreateNamedTypeDeclaration(
     INamedTypeSymbol namedType, CodeGenerationDestination destination, CodeGenerationOptions options, CancellationToken cancellationToken)
 {
     return(NamedTypeGenerator.GenerateNamedTypeDeclaration(this, namedType, destination, options, cancellationToken));
 }