Пример #1
0
        private BlockSyntax WrapByUsingStatements(
            IEnumerable <ParameterDescription> parametersDescription,
            BlockSyntax body)
        {
            StatementSyntax currentStatement = null;

            foreach (var parameter in parametersDescription)
            {
                if (JavaUtils.IsPrimitive(parameter.Type))
                {
                    continue;
                }

                var childBody = currentStatement ?? body;

                currentStatement = RoslynUtils.UsingStatement(
                    "var",
                    $"{parameter.Name}_using",
                    GetExpressionFor(parameter),
                    childBody);
            }

            return(currentStatement == null
                ? body
                : SyntaxFactory.Block(currentStatement));
        }