public static void Run() { var newElectricitySystem = new NewElectricitySystem(); ElectricityConsumer.ChargeNotebook(newElectricitySystem); var oldElectricitySystem = new OldElectricitySystem(); var adapter = new Adapter(oldElectricitySystem); ElectricityConsumer.ChargeNotebook(adapter); }
static void Main(string[] args) { var newElectricitySystem = new NewElectricitySystem(); ElectricityConsumer.ChargeNoteBook(newElectricitySystem); var oldElectricitySystem = new OldElectricitySystem(); ElectricityConsumer.ChargeNoteBook(new Adapter(oldElectricitySystem)); Console.ReadKey(); }
public static void Run() { // 1) // Ми можемо користуватися новою системою без проблем var newElectricitySystem = new NewElectricitySystem(); ElectricityConsumer.ChargeNotebook(newElectricitySystem); // 2) // Ми повинні адаптуватися до старої системи, використовуючи адаптер var oldElectricitySystem = new OldElectricitySystem(); var adapter = new Adapter(oldElectricitySystem); ElectricityConsumer.ChargeNotebook(adapter); }
public IActionResult Index() { var newElectricitySystem = new NewElectricitySystem(); ElectricityConsumer.ChargeNotebook(newElectricitySystem); // Ми повинні адаптуватися до старої системи, використовуючи адаптер var oldElectricitySystem = new OldElectricitySystem(); var adapter = new Adapter(oldElectricitySystem); ViewData["result"] = ElectricityConsumer.ChargeNotebook(adapter); return(View("ResultView")); }
public Adapter(OldElectricitySystem adaptee) { this._adaptee = adaptee; }
public Adapter(OldElectricitySystem adaptee) { _adaptee = adaptee; }