示例#1
0
        static void Main(string[] args)
        {
            SteveObserver       steveObserver = new SteveObserver();
            JohnObserver        johnObserver  = new JohnObserver();
            NotificationService service       = new NotificationService();

            service.AddSubscriber(johnObserver);
            service.AddSubscriber(steveObserver);
            service.NotifySubscriber();
            service.RemoveSubscriber(johnObserver);
            Console.ReadLine();
        }
示例#2
0
        static void Main(string[] args)
        {
            var steve = new SteveObserver();
            var john  = new JohnObserver();

            var noticificationService = new NotificationService();

            noticificationService.AddSubscriber(steve);
            noticificationService.AddSubscriber(john);

            noticificationService.NotifySubscriber();

            noticificationService.RemoveSubsriber(steve);
        }
示例#3
0
        private static void Main(string[] args)
        {
            INotificationService  notificationService = new NotificationService();
            INotificationObserver john  = new JohnObserver();
            INotificationObserver steve = new SteveObserver();

            notificationService.AddSubscriber(john);
            notificationService.AddSubscriber(steve);

            notificationService.NotifySubscriber();
            Console.WriteLine();
            notificationService.RemoveSubscriber(john);
            notificationService.NotifySubscriber();
        }