static void Main(string[] args)
        {
            JohnObserver  john  = new JohnObserver();
            SteveObserver steve = new SteveObserver();

            NotificationService service = new NotificationService();

            service.AddSubscriber(john);
            service.AddSubscriber(steve);
            service.NotifySubscriber();
            service.RemoveSubscriber(john);
            Console.Read();
        }
Esempio n. 2
0
        static void Main(string[] args)
        {
            INotificationService  notificationObserver = new NotificationService();
            INotificationObserver johnObserver         = new JohnObserver();
            INotificationObserver steveObserver        = new SteveObserver();

            Console.WriteLine("Subscriber's Added");
            notificationObserver.AddSubscriber(johnObserver);
            notificationObserver.AddSubscriber(steveObserver);
            notificationObserver.NotifySubscriber();
            Console.WriteLine("John is removed from Subscriber's list");
            notificationObserver.RemoveSubscriber(johnObserver);
            notificationObserver.NotifySubscriber();
        }
Esempio n. 3
0
        static void Main(string[] args)
        {
            Console.WriteLine("Hello World!");
            INotificationObserver steve = new SteveObserver()
            {
                Name = "Steve"
            };
            INotificationObserver john = new JohnObserver()
            {
                Name = "John"
            };
            INotificationService notification = new NotificationService();

            notification.AddSubscriber(steve);
            notification.AddSubscriber(john);

            notification.NotifySubscriber();

            notification.RemoveSubscriber(john);
        }