public static ForStatement Do(this ForStatement forStatement, Action<BlockStatement> block)
        {
            var nestedBlockStatement = new BlockStatement();
            block(nestedBlockStatement);

            forStatement.Body = nestedBlockStatement;
            return forStatement;
        }
Exemple #2
0
 public ForStatement()
 {
     Variable = ForVar;
     InitValue = 0;
     Condition = Variable < 0;
     Increment = Variable.PlusPlus();
     Body = new BlockStatement();
 }
        public static ConstructorStatement Ctor(this ClassStatement classStatement, Action<BlockStatement> block)
        {
            var blockStatement = new BlockStatement();
            block(blockStatement);

            var ctorStatement = new ConstructorStatement(classStatement.CsType, blockStatement);
            classStatement.AddConstructor(ctorStatement);
            return ctorStatement;
        }
        public ConstructorStatement(CsType type, BlockStatement block)
        {
            AccessModifier = AccessModifier.Public;

            this.type = type;
            body = block;
            parameterList = new ParameterListStatement();
            baseParameters = new List<Expression>();
        }
        public static MethodStatement Method(this ClassStatement classStatement, string name,
                                             Action<BlockStatement> block)
        {
            var blockStatement = new BlockStatement();
            block(blockStatement);

            var methodStatement = new MethodStatement(name, blockStatement);
            classStatement.AddMethod(methodStatement);
            return methodStatement;
        }
Exemple #6
0
        public FieldStatement(string name)
        {
            AccessModifier = AccessModifier.Public;
            Modifier = Modifier.Virtual;
            FieldType = CsType.String;

            this.name = new NameElement(name);
            attributes = new List<AttributeStatement>();
            blockStatement = new BlockStatement {SingleLine = true};
        }
        public static IfStatement If(this BlockStatement blockStatement, Expression expression,
                                     Action<BlockStatement> block)
        {
            var nestedBlockStatement = new BlockStatement();
            block(nestedBlockStatement);

            var ifStatement = new IfStatement(expression, nestedBlockStatement);
            blockStatement.AddStatement(ifStatement);
            return ifStatement;
        }
        public static ForeachStatement Foreach(this BlockStatement blockStatement, string itemName, Expression expression,
                                           Action<BlockStatement> block)
        {
            var nestedBlockStatement = new BlockStatement();
            block(nestedBlockStatement);

            var foreachStatement = new ForeachStatement(new NameElement(itemName), expression, nestedBlockStatement);
            blockStatement.AddStatement(foreachStatement);
            return foreachStatement;
        }
        public MethodStatement(string name, BlockStatement block)
        {
            AccessModifier = AccessModifier.Public;
            Modifier = Modifier.Virtual;
            ReturnType = CsType.Void;

            this.name = new NameElement(name);
            body = block;
            parameterList = new ParameterListStatement();
            attributes = new List<AttributeStatement>();
        }
Exemple #10
0
        public ClassStatement(string name)
        {
            AccessModifier = AccessModifier.Public;
            ClassModifier = ClassModifier.Empty;

            this.name = new NameElement(name);
            body = new BlockStatement();
            attributes = new List<AttributeStatement>();
            CsType = new CustomType(name);
            interfaces = new List<CsType>();
        }
        public PropertyStatement(string name)
        {
            AccessModifier = AccessModifier.Public;
            getAccesor = GetAccesor.Empty;
            Modifier = Modifier.Virtual;
            ReturnType = CsType.String;
            setAccesor = SetAccesor.Empty;

            this.name = new NameElement(name);
            attributes = new List<AttributeStatement>();
            blockStatement = new BlockStatement {SingleLine = true};
        }
        public static PropertyStatement Set(this PropertyStatement propertyStatement, Action<BlockStatement> block,
                                            bool multiLine = false, AccessModifier accessModifier = null)
        {
            var blockStatement = new BlockStatement { SingleLine = !multiLine };
            block(blockStatement);

            var setAccesor = new SetAccesor(blockStatement);
            propertyStatement.SetAccesor = setAccesor;
            propertyStatement.GetAccesor.AccessModifier = accessModifier;

            return propertyStatement;
        }
Exemple #13
0
 public IfStatement(Expression expression, BlockStatement body)
 {
     this.expression = expression;
     this.body = body;
 }
 public ForeachStatement(NameElement itemName, Expression collection, BlockStatement body)
 {
     this.itemName = itemName;
     this.collection=collection;
     this.body = body;
 }
        public static WhileStatement While(this BlockStatement blockStatement, Expression expression,
                                           Action<BlockStatement> block)
        {
            var nestedBlockStatement = new BlockStatement();
            block(nestedBlockStatement);

            var whileStatement = new WhileStatement(expression, nestedBlockStatement);
            blockStatement.AddStatement(whileStatement);
            return whileStatement;
        }