コード例 #1
0
        public static void TimeEventTesterEntry()
        {
            Clock        theclock = new Clock();
            DisplayClock dc       = new DisplayClock();

            dc.Subscribe(theclock);
            theclock.Run();
        }
コード例 #2
0
        public static void Main()
        {
            ClockPublisher clock = new ClockPublisher();

            ISubscriber dc = new DisplayClock(clock);
            ISubscriber lc = new LogClock(clock);

            lc.AddSubscriber();                   // subscribe for event
            dc.AddSubscriber();                   // subscribe for event

            clock.GetUpdatedTimeOnSecondChange(); // publish event

            Console.ReadKey();
        }
コード例 #3
0
        static void Main(string[] args)
        {
            // Create a new clock
            Clock theClock = new Clock();

            // Create the display and tell it to
            // subscribe to the clock just created
            DisplayClock dc = new DisplayClock();

            dc.Subscribe(theClock);

            // Create a Log object and tell it
            // to subscribe to the clock
            LogClock lc = new LogClock();

            lc.Subscribe(theClock);

            // Get the clock started
            theClock.Run();
        }