Пример #1
0
        public override SyntaxNode Generate(Context context)
        {
            var methodName = Mutations.GetValue("name").CreateValidName();

            var arguments = new List <ArgumentSyntax>();

            var counter = 0;

            foreach (var mutation in Mutations.Where(x => x.Domain == "arg" && x.Name == "name"))
            {
                var argumentExpression = this.Values.Generate($"ARG{counter}", context) as ExpressionSyntax;
                if (argumentExpression == null)
                {
                    throw new ApplicationException($"Unknown argument expression for ARG{counter}.");
                }

                arguments.Add(Argument(argumentExpression));
                counter++;
            }

            var methodInvocation =
                InvocationExpression(
                    IdentifierName(methodName)
                    );


            if (arguments.Any())
            {
                var syntaxList = SeparatedList(arguments);

                methodInvocation =
                    methodInvocation
                    .WithArgumentList(
                        ArgumentList(
                            syntaxList
                            )
                        );
            }

            return(Statement(methodInvocation, base.Generate(context), context));
        }