コード例 #1
0
        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)));
            }
        }
コード例 #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)));
            }
        }