示例#1
0
        private SyntaxNode MkEvents()
        {
            List <SyntaxNode>      evDeclarations           = new List <SyntaxNode>();
            List <StatementSyntax> eventInitializationStmts = new List <StatementSyntax>();
            string eventsClassName = "Events";

            //add halt event
            evDeclarations.Add(
                CSharpHelper.MkCSharpFieldDeclarationWithInit(SyntaxFactory.IdentifierName("PrtEventValue"),
                                                              "halt",
                                                              SyntaxFactory.Token(SyntaxKind.PublicKeyword),
                                                              SyntaxFactory.Token(SyntaxKind.StaticKeyword),
                                                              SyntaxFactory.MemberAccessExpression(SyntaxKind.SimpleMemberAccessExpression, SyntaxFactory.IdentifierName("PrtValue"), SyntaxFactory.IdentifierName("halt"))
                                                              )
                );

            //add null event
            evDeclarations.Add(
                CSharpHelper.MkCSharpFieldDeclarationWithInit(SyntaxFactory.IdentifierName("PrtEventValue"),
                                                              "@null",
                                                              SyntaxFactory.Token(SyntaxKind.PublicKeyword),
                                                              SyntaxFactory.Token(SyntaxKind.StaticKeyword),
                                                              SyntaxFactory.MemberAccessExpression(SyntaxKind.SimpleMemberAccessExpression, SyntaxFactory.IdentifierName("PrtValue"), SyntaxFactory.IdentifierName("@null"))
                                                              )
                );

            var eventsClass = generator.ClassDeclaration(
                eventsClassName, typeParameters: null,
                accessibility: Accessibility.Public,
                modifiers: DeclarationModifiers.Partial,
                members: evDeclarations);

            return(eventsClass);
        }