示例#1
0
 public CSFixedCodeBlock(CSType type, CSIdentifier ident, CSBaseExpression expr, IEnumerable <ICodeElement> body)
     : base(body)
 {
     Type       = Exceptions.ThrowOnNull(type, "type");
     Identifier = Exceptions.ThrowOnNull(ident, "ident");
     Expr       = Exceptions.ThrowOnNull(expr, "expr");
 }
 public ForElement(CSType type, CSIdentifier ident, CSBaseExpression expr)
     : base()
 {
     Type  = type;
     Ident = ident;
     Expr  = expr;
 }
 public CSTernary(CSBaseExpression predicate, CSBaseExpression onTrue, CSBaseExpression onFalse, bool addParentheses)
 {
     Predicate      = Exceptions.ThrowOnNull(predicate, "predicate");
     OnTrue         = Exceptions.ThrowOnNull(onTrue, "onTrue");
     OnFalse        = Exceptions.ThrowOnNull(onFalse, "onFalse");
     AddParentheses = addParentheses;
 }
        public static CSMethod PInvoke(CSVisibility vis, CSType type, string name, CSBaseExpression dllName, string externName, CSParameterList parms)
        {
            CSMethod method = new CSMethod(vis, CSMethodKind.StaticExtern, Exceptions.ThrowOnNull(type, "type"),
                                           new CSIdentifier(name), parms, null);

            CSAttribute.DllImport(dllName, externName).AttachBefore(method);

            return(method);
        }
 public CSForEach(CSType type, CSIdentifier ident, CSBaseExpression expr, CSCodeBlock body)
 {
     Type  = type;
     Ident = Exceptions.ThrowOnNull(ident, nameof(ident));
     Expr  = Exceptions.ThrowOnNull(expr, nameof(expr));
     Body  = body ?? new CSCodeBlock();
     Add(new ForElement(type, ident, expr));
     Add(Body);
 }
        public static CSAttribute DllImport(CSBaseExpression dllName, string entryPoint = null)
        {
            CSArgumentList args = new CSArgumentList();

            args.Add(dllName);
            if (entryPoint != null)
            {
                args.Add(new CSAssignment("EntryPoint", CSAssignmentOperator.Assign, CSConstant.Val(entryPoint)));
            }
            return(new CSAttribute(new CSIdentifier("DllImport"), args, true));
        }
        public CSIfElse(CSBaseExpression condition, CSCodeBlock ifClause, CSCodeBlock elseClause = null)
            : base()
        {
            Condition  = new CSIfElement(Exceptions.ThrowOnNull(condition, "condition"));
            IfClause   = Exceptions.ThrowOnNull(ifClause, "ifClause");
            ElseClause = elseClause;

            Add(Condition);
            Add(IfClause);
            if (ElseClause != null && ElseClause.Count > 0)
            {
                Add(new SimpleLineElement("else", false, true, false));
                Add(ElseClause);
            }
        }
 public CSForEach(CSType type, string ident, CSBaseExpression expr, CSCodeBlock body)
     : this(type, new CSIdentifier(ident), expr, body)
 {
 }
示例#9
0
 public static CSLine Assign(CSBaseExpression name, CSAssignmentOperator op, CSBaseExpression value)
 {
     return(new CSLine(new CSAssignment(name, op, value)));
 }
示例#10
0
 public CSBaseExpression Dot(CSBaseExpression rhs)
 {
     return(new CSBinaryExpression(CSBinaryOperator.Dot, this, rhs));
 }
示例#11
0
 public CSAssignment(CSBaseExpression lhs, CSAssignmentOperator op, CSBaseExpression rhs)
 {
     Target    = Exceptions.ThrowOnNull(lhs, "lhs");
     Value     = Exceptions.ThrowOnNull(rhs, "rhs");
     Operation = op;
 }
示例#12
0
 public static CSLine Assign(CSBaseExpression name, CSBaseExpression value)
 {
     return(Assign(name, CSAssignmentOperator.Assign, value));
 }
示例#13
0
 public CSAssignment(string lhs, CSAssignmentOperator op, CSBaseExpression rhs)
     : this(new CSIdentifier(Exceptions.ThrowOnNull(lhs, "lhs")), op, rhs)
 {
 }
		public static CSFunctionCall Sizeof (CSBaseExpression expr)
		{
			CommaListElementCollection<CSBaseExpression> parms = new CommaListElementCollection<CSBaseExpression> ();
			parms.Add (expr);
			return new CSFunctionCall (iSizeof, parms, false);
		}
示例#15
0
 public CSIndexExpression(CSBaseExpression aggregate, bool addParensAroundAggregate, params CSBaseExpression [] parameters)
     : this(aggregate, new CommaListElementCollection <CSBaseExpression> (parameters), addParensAroundAggregate)
 {
 }
示例#16
0
        public CSIfElse(CSBaseExpression expr, IEnumerable <ICodeElement> ifClause, IEnumerable <ICodeElement> elseClause)
            : this(expr, new CSCodeBlock(ifClause),
                   elseClause != null ? new CSCodeBlock(elseClause) : null)

        {
        }
示例#17
0
 public CSIndexExpression(CSBaseExpression aggregate, CommaListElementCollection <CSBaseExpression> paramList, bool addParensAroundAggregate)
 {
     AddParensAroundAggregate = addParensAroundAggregate;
     Aggregate  = Exceptions.ThrowOnNull(aggregate, "aggregate");
     Parameters = Exceptions.ThrowOnNull(paramList, "paramList");
 }
示例#18
0
 public CSIfElement(CSBaseExpression condition)
     : base()
 {
     Condition = condition;
 }
示例#19
0
 public CSThrow(CSBaseExpression expr)
 {
     Expr = Exceptions.ThrowOnNull(expr, "expr");
 }