public static void Main(string[] args)
        {
            Publisher publisher = new Publisher();

            SendViaMobile send2Mobile = new SendViaMobile("416 1234567");

            SendViaMobile send2Mobile2 = new SendViaMobile("416 1239999");

            SendViaMobile send2Mobile3 = new SendViaMobile("647 123 4567");

            SendViaEmail send2Email = new SendViaEmail("*****@*****.**");

            SendViaEmail send3Email = new SendViaEmail("*****@*****.**");

            SendViaEmail sub2 = new SendViaEmail("*****@*****.**");

            //Subscribing for Mobile notifications
            sub2.Subscribe(publisher);
            send2Mobile.Subscribe(publisher);

            send2Mobile2.Subscribe(publisher);

            send2Mobile3.Subscribe(publisher);

            send3Email.Subscribe(publisher);

            //Emails are not subscribed so it wont receive notifications via Email
            send2Email.Subscribe(publisher);

            //Invoking the delegate Only Mobile will receive notifications.
            publisher.PublishMessage("Hello You Have New Notifications");

            Console.WriteLine();

            send2Mobile3.UnSubscribe(publisher);
            send2Email.UnSubscribe(publisher);
            publisher.PublishMessage("Hello You Have More New Notifications");

            Console.ReadKey();
        }
예제 #2
0
        static void Main(string[] args)
        {
            Publisher publisher = new Publisher();

            SendViaMobile send2Mobile = new SendViaMobile("647 1234567");
            SendViaEmail  send2Email  = new SendViaEmail("*****@*****.**");

            send2Mobile.Subscribe(publisher);
            send2Email.Subscribe(publisher);

            publisher.PublishMessage("Hello!!! You have new notifications");
            Console.ReadKey();
        }
예제 #3
0
        static void Main(string[] args)
        {
            Publisher publisher = new Publisher();

            SendViaMobile send2Mobile = new SendViaMobile("647 1234567");
            SendViaEmail send2Email = new SendViaEmail("*****@*****.**");

            send2Mobile.Subscribe(publisher);
            send2Email.Subscribe(publisher);

            publisher.PublishMessage("Hello!!! You have new notifications");
            Console.ReadKey();


        }
        public static void ExecuteMain()
        {
            /* Example obj = new Example();
             * // 2. Instantiation
             * MyDelagate multicastdel = new MyDelagate(obj.Sum);
             * multicastdel += new MyDelagate(obj.Difference);
             *
             * // 3. Invocation
             * multicastdel(50, 20);*/

            Publisher publisher = new Publisher();

            SendViaEmail  SE = new SendViaEmail();
            SendViaMobile SM = new SendViaMobile();

            publisher.publishmsg += SE.sendEmail;
            publisher.publishmsg += SM.sendMessage;

            publisher.PublishMessage(" you have new notifications");
        }