} // end GenerateAuthorName(); internal void printLogins ( EntityLogin login ) { if ( login == null ) foreach ( EntityLogin loopLogin in Logins ) if ( loopLogin.postList != null ) { Console.WriteLine("\n\n\n\nPosts of user '{0}':", loopLogin.name); foreach ( Post post in loopLogin.postList ) Console.WriteLine("Thread: {0} Section: {1} Author: {2} Content: {3}", post.ThreadName, post.SectionName, post.Author, post.Content); } else Console.WriteLine("No posts for user {0}.", loopLogin.name); else if ( login.postList != null ) { Console.WriteLine("\n\n\n\nPosts of user '{0}':", login.name); foreach ( Post post in login.postList ) Console.WriteLine("Thread: {0} Section: {1} Author: {2} Content: {3}", post.ThreadName, post.SectionName, post.Author, post.Content); } else Console.WriteLine("No posts for user {0}.", login.name); } // end printLogins(EntityLogin);
/* 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();