public static void Main(string[] args) { MagazineCollection mag1 = new MagazineCollection(); MagazineCollection mag2 = new MagazineCollection(); mag1.CollectionName = "mag1"; mag2.CollectionName = "mag2"; Listener lis1 = new Listener(); mag1.MagazineAdded += lis1.AddEvent; mag1.MagazineReplaced += lis1.AddEvent; Listener lis2 = new Listener(); mag1.MagazineAdded += lis2.AddEvent; mag2.MagazineAdded += lis2.AddEvent; mag1.MagazineReplaced += lis2.AddEvent; mag2.MagazineReplaced += lis2.AddEvent; mag1.AddMagazines(new Magazine()); mag2.AddMagazines(new Magazine()); mag1.AddDefaults(); mag2.AddDefaults(); mag1.Magazines.Remove(mag1[2]); mag2.Magazines.Remove(mag2[2]); mag1.AddDefaults(); mag2.AddDefaults(); mag1[2] = new Magazine(); mag1.Replace(1, new Magazine()); mag2[2] = new Magazine(); mag2.Replace(1, new Magazine()); Console.WriteLine("-------------LISTENER-1-------------"); Console.WriteLine(lis1); Console.WriteLine("-------------LISTENER-2-------------"); Console.WriteLine(lis2); }
static void Main(string[] args) { Magazine magazine = new Magazine("Daily Buglees", Frequency.Monthly, new DateTime(2010, 12, 12), 250000); magazine.AddArticles(new Article(new Person("Nick", "Back", new DateTime(1990, 10, 20)), "Corona-Time", 2.2)); magazine.AddEditors(new Person("Kek", "lol", new DateTime(1988, 8, 7))); MagazineCollection collection1 = new MagazineCollection() { CollectionName = "collection1" }; MagazineCollection collection2 = new MagazineCollection() { CollectionName = "collection2" }; Listener listener1 = new Listener(); Listener listener2 = new Listener(); collection1.MagazineAdded += listener1.MagazineListHandler; collection1.MagazineReplaced += listener1.MagazineListHandler; collection2.MagazineAdded += listener2.MagazineListHandler; collection2.MagazineReplaced += listener2.MagazineListHandler; collection1.AddDefaults(); collection1.AddMagazines(magazine); collection2.AddMagazines(magazine); collection1.Replace(0, collection2[0]); collection2[0] = collection1[1]; Console.WriteLine("Listener1:\n" + listener1); Console.WriteLine("Listener2:\n" + listener2); }