Ejemplo n.º 1
0
        private static StatementSyntax GenerateRegisterCommandStatement(string id)
        {
            string str1 = NameMaker.MakeExecuteCommandMethodName(id);
            string str2 = NameMaker.MakeBeforeQueryStatusMethodName(id);

            return(SyntaxFactory.ExpressionStatement(SyntaxFactory.InvocationExpression(SyntaxFactory.IdentifierName("RegisterCommand")).WithArgumentList(SyntaxFactory.ArgumentList(SyntaxFactory.SeparatedList <ArgumentSyntax>(new SyntaxNodeOrToken[]
            {
                SyntaxFactory.Argument(SyntaxFactory.IdentifierName("service")),
                SyntaxFactory.Token((SyntaxKind)8216),
                SyntaxFactory.Argument(SyntaxFactory.MemberAccessExpression((SyntaxKind)8689, SyntaxFactory.IdentifierName("CommandIds"), SyntaxFactory.IdentifierName(NameMaker.MakeCommandIDName(id)))),
                SyntaxFactory.Token((SyntaxKind)8216),
                SyntaxFactory.Argument(SyntaxFactory.MemberAccessExpression((SyntaxKind)8689, SyntaxFactory.IdentifierName("facade"), SyntaxFactory.IdentifierName(str1))),
                SyntaxFactory.Token((SyntaxKind)8216),
                SyntaxFactory.Argument(SyntaxFactory.MemberAccessExpression((SyntaxKind)8689, SyntaxFactory.IdentifierName("facade"), SyntaxFactory.IdentifierName(str2)))
            })))));
        }
Ejemplo n.º 2
0
        public static ClassDeclarationSyntax GenerateCommandIdsClass(XDocument vsctDocument)
        {
            SyntaxList <MemberDeclarationSyntax> syntaxList = SyntaxFactory.List <MemberDeclarationSyntax>();
            XElement xelement = vsctDocument.Root.Element(XNames.Commands).Element(XNames.Buttons);

            if (xelement != null && xelement.HasElements)
            {
                foreach (XElement element in xelement.Elements(XNames.Button))
                {
                    string str = element.AttributeValueNull("id");
                    NameMaker.MakeCommandIDName(str);
                    string nameForButtonName = VsctHelper.GetGuidSymbolNameForButtonName(vsctDocument, str);
                    syntaxList = @syntaxList.Add(FieldGenerator.GenerateCommandIDField(str, nameForButtonName));
                }
            }
            return(SyntaxFactory.ClassDeclaration("CommandIds")
                   .WithModifiers(Modifiers.InternalStaticPartial)
                   .WithMembers(syntaxList)
                   .NormalizeWhitespace());
        }
Ejemplo n.º 3
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());
        }