/* Constructors */ public DataGenerator ( ) { Producers = new List <EntityProducer> (); Logins = new List <EntityLogin> (); Posts = new List <Post> (); EntityProducer producer = null; EntityLogin login = null; string name; // Generation of posts for ( int i = 0; i < 100; ++i ) Posts.Add(new Post(GeneratePostName(), GenerateSectionName(), null, null, new DateTime())); // Generation of logins for ( int i = 10; i > 0; --i ) { login = new EntityLogin(name = GenerateAuthorName()); foreach ( Post post in Posts ) { if ( post.Author == null && ( random.Next(0, 5) == 0 || i == 1 ) ) { login.addPost(post); post.Author = name; } } Logins.Add(login); } // Generation of producers for ( int i = 10; i > 0; --i ) { producer = new EntityProducer(name = GenerateProducerName()); foreach ( Post post in Posts ) if ( random.Next(0, 5) == 0 || i == 1 ) { producer.addPost(post); post.Content = post.Content + ", " + name; } Producers.Add(producer); } } // end DataGenerator();
} // end printLogins(EntityLogin); internal void printProducers ( EntityProducer producer ) { if ( producer == null ) foreach ( EntityProducer loopProducer in Producers ) if ( loopProducer.postList != null ) { Console.WriteLine("\n\n\n\nPosts containing producer '{0}':", loopProducer.name); foreach ( Post post in loopProducer.postList ) Console.WriteLine("Thread: {0} Section: {1} Author: {2} Content: {3}", post.ThreadName, post.SectionName, post.Author, post.Content); } else Console.WriteLine("No posts containing producer {0}.", loopProducer.name); else if ( producer.postList != null ) { Console.WriteLine("\n\n\n\nPosts containing producer '{0}':", producer.name); foreach ( Post post in producer.postList ) Console.WriteLine("Thread: {0} Section: {1} Author: {2} Content: {3}", post.ThreadName, post.SectionName, post.Author, post.Content); } else Console.WriteLine("No posts containing producer {0}.", producer.name); } // end printLogins(EntityProducer);