Пример #1
0
 static void Main(string[] args)
 {
     Shape shape = new Shape();
     Sub1 sb = new Sub1(shape);
     Sub2 sb2 = new Sub2(shape);
     shape.Draw();
 }
        static void Main(string[] args)
        {
            Shape shape = new Shape();
            Subscriber1 sub = new Subscriber1(shape);
            Subscriber2 sub2 = new Subscriber2(shape);
            shape.Draw();

            // Keep the console window open in debug mode.
            System.Console.WriteLine("Press any key to exit.");
            System.Console.ReadKey();
        }
Пример #3
0
 public Sub2(Shape shape)
 {
     IShape obj = (IShape)shape;
     obj.OnDraw += new EventHandler(obj_OnDraw);
 }
Пример #4
0
 public Sub1(Shape shape)
 {
     IDrawObject obj = (IDrawObject)shape;
     obj.OnDraw += new EventHandler(obj_OnDraw);
 }
 public Subscriber2(Shape shape)
 {
     IShape d = (IShape)shape;
     d.OnDraw += new EventHandler(d_OnDraw);
 }
 // References the shape object as an IDrawingObject
 public Subscriber1(Shape shape)
 {
     IDrawingObject d = (IDrawingObject)shape;
     d.OnDraw += new EventHandler(d_OnDraw);
 }