public static SyntaxerImmutableCollection<ParameterSyntax> Parameter(
            this SyntaxerImmutableCollection<ParameterSyntax> parameters,
            SyntaxerName parameterName,
            SyntaxerTypeName type)
        {
            Must.Assert<ArgumentNullException>(parameters != null);

            return parameters.Add(parameters.Syntaxer.Parameter(parameterName, type));
        }
예제 #2
0
        public static ParameterSyntax Parameter(
            this ISyntaxerContext syntaxer,
            SyntaxerName parameterName,
            SyntaxerTypeName type)
        {
            Must.Assert<ArgumentNullException>(syntaxer != null);

            var _parameter = SyntaxFactory.Parameter(parameterName)
                .WithType(type);

            return _parameter;
        }
        public static LocalDeclarationStatementSyntax LocalDeclarationStatement(
            this ISyntaxerContext syntaxer,
            SyntaxerName variableName,
            ExpressionSyntax assignment = null,
            SyntaxerTypeName type = default(SyntaxerTypeName))
        {
            Must.Assert<ArgumentNullException>(syntaxer != null);

            var _variableDeclarator = SyntaxFactory.VariableDeclarator(variableName);

            if (assignment != null)
            {
                _variableDeclarator = _variableDeclarator.WithInitializer(SyntaxFactory.EqualsValueClause(assignment));
            }

            var _statement = SyntaxFactory.LocalDeclarationStatement(
                SyntaxFactory.VariableDeclaration(
                    type.TypeSyntax ?? SyntaxFactory.IdentifierName("var"),
                    SyntaxFactory.SingletonSeparatedList(_variableDeclarator)));

            return _statement;
        }