Exemplo n.º 1
0
        public static void Main(string[] args)
        {
            MagazineCollection magazine1 = new MagazineCollection();
            MagazineCollection magazine2 = new MagazineCollection();

            magazine1.CollectionName = "Magazine1";
            magazine2.CollectionName = "Magazine2";

            Listener listener1 = new Listener();

            magazine1.MagazineAdded    += listener1.AddEvent;
            magazine1.MagazineReplaced += listener1.AddEvent;

            Listener listener2 = new Listener();

            magazine1.MagazineAdded    += listener2.AddEvent;
            magazine2.MagazineAdded    += listener2.AddEvent;
            magazine1.MagazineReplaced += listener2.AddEvent;
            magazine2.MagazineReplaced += listener2.AddEvent;

            magazine1.AddMagazines(new Magazine());
            magazine2.AddMagazines(new Magazine());
            magazine1.AddDefaults();
            magazine2.AddDefaults();

            Console.WriteLine("<<<<<<<<<<<< LISTENER 1 >>>>>>>>>>>>");
            Console.WriteLine(listener1);

            Console.WriteLine();

            Console.WriteLine("<<<<<<<<<<<< LISTENER 2 >>>>>>>>>>>>");
            Console.WriteLine(listener2);

            Console.ReadKey();
        }
Exemplo n.º 2
0
        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();


            Console.WriteLine("-------------LISTENER-1-------------");
            Console.WriteLine(lis1);
            Console.WriteLine("-------------LISTENER-2-------------");
            Console.WriteLine(lis2);
            Console.ReadKey();
        }
Exemplo n.º 3
0
        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);
        }