Exemplo n.º 1
0
        public static ClassDeclarationSyntax GenerateCommandRegistrarClass(XDocument vsctDocument)
        {
            MethodDeclarationSyntax registerCommandMethod  = MethodGenerator.GenerateRegisterCommandMethod();
            MethodDeclarationSyntax registerCommandsMethod = MethodGenerator.GenerateRegisterCommandsMethod(vsctDocument);

            return(SyntaxFactory.ClassDeclaration("CommandRegistrar").WithModifiers(Modifiers.InternalStaticPartial).WithMembers(SyntaxFactory.List <MemberDeclarationSyntax>(new MemberDeclarationSyntax[2]
            {
                registerCommandsMethod,
                registerCommandMethod
            })));
        }
Exemplo n.º 2
0
        public static ClassDeclarationSyntax GenerateAbstractCommandFacadeClass(XDocument vsctDocument)
        {
            SyntaxList <MemberDeclarationSyntax> syntaxList = SyntaxFactory.List <MemberDeclarationSyntax>();

            syntaxList = @syntaxList.Add(ClassGenerator.GenerateProtectedConstructor("AbstractCommandFacade"));
            XElement xelement = vsctDocument.Root.Element(XNames.Commands).Element(XNames.Buttons);

            if (xelement != null && xelement.HasElements)
            {
                foreach (XElement element in xelement.Elements(XNames.Button))
                {
                    string id           = element.Attribute("id").Value;
                    string commandName1 = NameMaker.MakeExecuteCommandMethodName(id);
                    string commandName2 = NameMaker.MakeBeforeQueryStatusMethodName(id);
                    syntaxList = @syntaxList.Add(MethodGenerator.GenerateFacadeCommandMethod(commandName1));
                    syntaxList = @syntaxList.Add(MethodGenerator.GenerateFacadeCommandMethod(commandName2));
                }
            }
            return(SyntaxFactory.ClassDeclaration("AbstractCommandFacade")
                   .WithModifiers(Modifiers.InternalAbstractPartial)
                   .WithMembers(syntaxList)
                   .NormalizeWhitespace());
        }