Ejemplo n.º 1
0
        public PostCommoditiesIterator(Journal journal)
        {
            Posts     = new XactPostsIterator();
            XactTemps = new List <Xact>();
            Temps     = new Temporaries();

            Reset(journal);
        }
Ejemplo n.º 2
0
        /// <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);
        }
Ejemplo n.º 3
0
 public void Reset(Journal journal)
 {
     Xacts = new XactsIterator(journal);
     Posts = new XactPostsIterator();
 }