コード例 #1
0
        private static string CreateClass_ColorNames(List <ColorEntity> entities, ProgressBar progress)
        {
            string classDeclaration;

            using (var child = progress.Spawn(entities.Count, "enum items added", childOptions))
            {
                var members = entities.Select((entity, index) =>
                {
                    //double prog = (double)index / entities.Count / STEPS;
                    //progress.Report(PROGRESS_STEP * lastStep + prog);

                    child.Tick();

                    // Console.WriteLine($"Converted {index} of {entities.Count} entities!");
                    return(Syntax.EnumMemberDeclaration(identifier:
                                                        Syntax.Identifier(entity.Name.SanitizeEnum())));
                });

                // TODO
                // Console.WriteLine("Declaring enum!");
                var declaration = Syntax.EnumDeclaration(
                    new SyntaxList <AttributeListSyntax>(),
                    identifier: Syntax.Identifier("ColorNames"),
                    modifiers: Syntax.TokenList(Syntax.Token(SyntaxKind.PublicKeyword)),
                    baseList: null,
                    members: Syntax.SeparatedList(members))
                                  .NormalizeWhitespace();

                classDeclaration = declaration.ToFullString();
            }

            return(classDeclaration);
        }
コード例 #2
0
ファイル: EnumGenerator.cs プロジェクト: seawatts/jsii
 protected override MemberDeclarationSyntax CreateType()
 {
     return(SF.EnumDeclaration
            (
                CreateAttributes(),
                SF.TokenList(SF.Token(SyntaxKind.PublicKeyword)),
                Symbols.GetNameSyntaxToken(Type),
                null,
                CreateValues()
            ));
 }