protected override TDeclarationNode AddField <TDeclarationNode>(TDeclarationNode destination, IFieldSymbol field, CodeGenerationOptions options, IList <bool> availableIndices)
        {
            CheckDeclarationNode <EnumDeclarationSyntax, TypeDeclarationSyntax, CompilationUnitSyntax>(destination);

            if (destination is EnumDeclarationSyntax)
            {
                return(Cast <TDeclarationNode>(EnumMemberGenerator.AddEnumMemberTo(Cast <EnumDeclarationSyntax>(destination), field, options)));
            }
            else if (destination is TypeDeclarationSyntax)
            {
                return(Cast <TDeclarationNode>(FieldGenerator.AddFieldTo(Cast <TypeDeclarationSyntax>(destination), field, options, availableIndices)));
            }
            else
            {
                return(Cast <TDeclarationNode>(FieldGenerator.AddFieldTo(Cast <CompilationUnitSyntax>(destination), field, options, availableIndices)));
            }
        }
Exemple #2
0
        protected override TDeclarationNode AddField <TDeclarationNode>(TDeclarationNode destination, IFieldSymbol field, CSharpCodeGenerationContextInfo info, IList <bool>?availableIndices, CancellationToken cancellationToken)
        {
            CheckDeclarationNode <EnumDeclarationSyntax, TypeDeclarationSyntax, CompilationUnitSyntax>(destination);

            if (destination is EnumDeclarationSyntax)
            {
                return(Cast <TDeclarationNode>(EnumMemberGenerator.AddEnumMemberTo(Cast <EnumDeclarationSyntax>(destination), field, info, cancellationToken)));
            }
            else if (destination is TypeDeclarationSyntax)
            {
                return(Cast <TDeclarationNode>(FieldGenerator.AddFieldTo(Cast <TypeDeclarationSyntax>(destination), field, info, availableIndices, cancellationToken)));
            }
            else
            {
                return(Cast <TDeclarationNode>(FieldGenerator.AddFieldTo(Cast <CompilationUnitSyntax>(destination), field, info, availableIndices, cancellationToken)));
            }
        }
 public override SyntaxNode CreateFieldDeclaration(IFieldSymbol field, CodeGenerationDestination destination, CodeGenerationOptions options)
 {
     return(destination == CodeGenerationDestination.EnumType
         ? EnumMemberGenerator.GenerateEnumMemberDeclaration(field, null, options)
         : (SyntaxNode)FieldGenerator.GenerateFieldDeclaration(field, destination, options));
 }