public void AdapterSucceeds() { TreasureBoxFrameworkService service = new TreasureBoxFrameworkService(); MyGameTreasureBox myBox = new MyGameTreasureBox(); FrameworkTreasureBoxAdapter boxAdapter = new FrameworkTreasureBoxAdapter(myBox); string loot = service.OpenTreasureBox(boxAdapter); }
/// <summary> /// Public constructor. /// </summary> /// <param name="myBox">A <see cref="MyGameTreasureBox"/>.</param> /// <remarks> /// This implementation of Adapter uses the object-composition approach. While the class implments the /// framework interface, it requires an instance of the custom interface. /// </remarks> public FrameworkTreasureBoxAdapter(MyGameTreasureBox myBox) { this._myBox = myBox; }