Ejemplo n.º 1
0
 public override CodeIterationStatement GenerateCodeDom(ICodeDOMTranslationOptions options)
 {
     #if LIGHT_CORE
     IEnumeratorExp enumMemberExp;
     enumMemberExp = new IEnumeratorExp(enumMember.GetReference());
     #endif
     CodeIterationStatement result = new CodeIterationStatement();
     result.Statements.Add(new CodeCommentStatement(String.Format("foreach ({0} {1} in {2})", this.currentMember.LocalType.TypeInstance.GetTypeName(options), this.enumMember.Name, _OIL._Core.GenerateExpressionSnippet(options, this.enumeratorSource.GenerateCodeDom(options)))));
     #if LIGHT_CORE
     //LIGHT_CORE
     result.InitStatement  = this.enumMember.GetDeclarationStatement().GenerateCodeDom(options);
     result.TestExpression = enumMemberExp.MoveNext().GenerateCodeDom(options);
     #else
     result.TestExpression = enumMember.GetReference().GetMethod("MoveNext").Invoke().GenerateCodeDom(options);
     #endif
     result.IncrementStatement = new CodeSnippetStatement("");
     result.Statements.AddRange(this.Statements.GenerateCodeDom(options));
     return(result);
 }
Ejemplo n.º 2
0
 public EnumeratorStatement(IStatementBlock sourceBlock)
     : base(sourceBlock)
 {
     enumMember                = this.Statements.Locals.AddNew(this.Statements.Locals.GetUnusedName("__enumerator"), typeof(IEnumerator).GetTypeReference());
     enumMember.AutoDeclare    = false;
     currentMember             = this.Statements.Locals.AddNew(this.Statements.Locals.GetUnusedName("__current"), typeof(void).GetTypeReference());
     currentMember.AutoDeclare = true;
     currentMemberInit         = new CastExpression(enumMember.GetReference().GetProperty("Current"), itemType);
     currentMember.InitializationExpression = currentMemberInit;
 }