public PostCommoditiesIterator(Journal journal) { Posts = new XactPostsIterator(); XactTemps = new List <Xact>(); Temps = new Temporaries(); Reset(journal); }
/// <summary> /// Ported from void generate_posts_iterator::increment /// </summary> public IEnumerable <Post> Get() { IList <Post> posts = new List <Post>(); int i = 0; while (i < Quantity) { string buf = GenerateXact(); Logger.Current.Debug("generate.post", () => String.Format("The post we intend to parse:\r\n{0}", buf)); try { ParseContextStack parsingContext = new ParseContextStack(); parsingContext.Push(new TextualReader(FileSystem.GetStreamReaderFromString(buf))); parsingContext.GetCurrent().Journal = Session.Journal; parsingContext.GetCurrent().Scope = Session; if (Session.Journal.Read(parsingContext) != 0) { Validator.Verify(() => Session.Journal.Xacts.Last().Valid()); XactPostsIterator iterPosts = new XactPostsIterator(Session.Journal.Xacts.Last()); foreach (Post post in iterPosts.Get()) { if (i++ >= Quantity) { break; } posts.Add(post); } } } catch { ErrorContext.Current.AddErrorContext(String.Format("While parsing generated transaction (seed {0}):", Seed)); ErrorContext.Current.AddErrorContext(buf.ToString()); throw; } } return(posts); }
public void Reset(Journal journal) { Xacts = new XactsIterator(journal); Posts = new XactPostsIterator(); }