예제 #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);
 }