/// <summary> /// Adds the elements of another StatementCollection to the end of this StatementCollection. /// </summary> /// <param name="items"> /// The StatementCollection whose elements are to be added to the end of this StatementCollection. /// </param> public virtual void AddRange(StatementCollection items) { foreach (Statement item in items) { this.List.Add(item); } }
/// <summary> /// Initializes a new instance of the StatementCollection class, containing elements /// copied from another instance of StatementCollection /// </summary> /// <param name="items"> /// The StatementCollection whose elements are to be added to the new StatementCollection. /// </param> public StatementCollection(StatementCollection items) { this.AddRange(items); }
public Enumerator(StatementCollection collection) { this.wrapped = ((System.Collections.CollectionBase)collection).GetEnumerator(); }
public void ToCodeDomSnippet(StatementCollection sts) { throw new Exception("not supported yet"); }
public void ToCodeDomFull(StatementCollection sts) { // create enumrator and initialize it sts.Add( Stm.Comment("<foreach>") ); sts.Add( Stm.Comment("This loop mimics a foreach call. See C# programming language, pg 247") ); sts.Add( Stm.Comment("Here, the enumerator is seale and does not implement IDisposable") ); VariableDeclarationStatement enDecl = Stm.Var( typeof(IEnumerator), "enumerator", this.Collection.Method("GetEnumerator").Invoke() ); sts.Add(enDecl); // get expression VariableReferenceExpression en = Expr.Var(enDecl); // iterate IterationStatement iter = Stm.While( en.Method("MoveNext").Invoke() ); sts.Add(iter); // get local parameter VariableDeclarationStatement localDecl = Stm.Var( this.LocalType, this.LocalName ); localDecl.InitExpression = (en.Prop("Current")).Cast(this.LocalType); iter.Statements.Add(localDecl); // add statements iter.Statements.Add(Stm.Comment("foreach body")); iter.Statements.AddRange(this.body); sts.Add( Stm.Comment("</foreach>") ); }
public override void ToCodeDom(CodeStatementCollection statements) { StatementCollection sts = new StatementCollection(); switch(this.outputType) { case ForEachType.Snippet: ToCodeDomSnippet(sts); break; default: ToCodeDomFull(sts); break; } sts.ToCodeDom(statements); }
/// <summary> /// Initializes a new instance of the StatementCollection class, containing elements /// copied from another instance of StatementCollection /// </summary> /// <param name="items"> /// The StatementCollection whose elements are to be added to the new StatementCollection. /// </param> public StatementCollection(StatementCollection items) { this.AddRange(items); }
public Enumerator(StatementCollection collection) { this.wrapped = ((System.Collections.CollectionBase)collection).GetEnumerator(); }