public static void Run() { ShapePublisher shape = new ShapePublisher(); Subscriber1 sub = new Subscriber1(shape); Subscriber2 sub2 = new Subscriber2(shape); shape.Draw(); }
public Subscriber2(ShapePublisher shape) { IShape d = (IShape)shape; d.OnDraw += d_OnDraw; }
// References the shape object as an IDrawingObject public Subscriber1(ShapePublisher shape) { IDrawingObject d = (IDrawingObject)shape; d.OnDraw += d_OnDraw; }