Ejemplo n.º 1
0
    static void Main(string[] args)
    {
        Incrementer incrementer  = new Incrementer();
        Dozens      dozenCounter = new Dozens(incrementer);

        incrementer.DoCount();
        Console.WriteLine("number of dozen = {0}", dozenCounter.DozenCount);
    }
Ejemplo n.º 2
0
    static void Main()
    {
        Incrementer incrementer   = new Incrementer();
        Dozens      dozensCounter = new Dozens(incrementer);

        incrementer.DoCount();
        Console.WriteLine("Number of dozens = {0}", dozensCounter.DozensCount);
    }
Ejemplo n.º 3
0
    static void Main()
    {
        var    incrementer   = new Incrementer();
        Dozens dozensCounter = new Dozens(incrementer);

        incrementer.DoCount();
        Console.WriteLine(dozensCounter.DozensCount);
    }
Ejemplo n.º 4
0
        public void _01()
        {
            var incrementer = new Incrementer();
            var dozens      = new Dozens(incrementer);

            incrementer.DoCount();
            Assert.Equal(9, dozens.DozensCount);
        }
Ejemplo n.º 5
0
    static void Main(string[] args)
    {
        Incrementer incrementer  = new Incrementer();                        // สร้าง publisher
        Dozens      dozenCounter = new Dozens(incrementer);                  // สร้าง subscriber โดยระบุ publisher เป็น parameter

        incrementer.DoCount();                                               // จำลองสถานการณ์ที่ firing event
        Console.WriteLine("number of dozen = {0}", dozenCounter.DozenCount); // รายงานสรุป
    }
Ejemplo n.º 6
0
        public void _01()
        {
            var incrementer = new Incrementer();

            incrementer.CountedADozen += (_, incrementerEventArgs) => { testOutputHelper.WriteLine(incrementerEventArgs.IterationCount.ToString()); };

            incrementer.DoCount();
        }
Ejemplo n.º 7
0
        public void demo3()
        {
            Incrementer incrementer = new Incrementer();
            //Dozens dozensCounter = new Dozens(incrementer);
            Dozens dozensCounter = new Dozens();

            incrementer.CoutedADozen += dozensCounter.IncrementDozensCount;
            incrementer.DoCount();
            Console.WriteLine("dozensCount:{0}", dozensCounter.DozensCount);
        }
Ejemplo n.º 8
0
    static void Main()
    {
        Incrementer incrementer = new Incrementer();       // instantiate Publisher
        Dozens dozensCounter    = new Dozens(incrementer); // instantiate Subscriber

        incrementer.DoCount();                             // invoke method in Publisher, which will raise event.
        Console.WriteLine("Number of dozens = {0}",
                          dozensCounter.DozensCount);
        Console.ReadLine();
    }