示例#1
0
        public static void Run()
        {
            var newElectricitySystem = new NewElectricitySystem();

            ElectricityConsumer.ChargeNotebook(newElectricitySystem);

            var oldElectricitySystem = new OldElectricitySystem();
            var adapter = new Adapter(oldElectricitySystem);

            ElectricityConsumer.ChargeNotebook(adapter);
        }
示例#2
0
        static void Main(string[] args)
        {
            var newElectricitySystem = new NewElectricitySystem();

            ElectricityConsumer.ChargeNoteBook(newElectricitySystem);

            var oldElectricitySystem = new OldElectricitySystem();

            ElectricityConsumer.ChargeNoteBook(new Adapter(oldElectricitySystem));

            Console.ReadKey();
        }
示例#3
0
    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);
    }
示例#4
0
        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"));
        }
示例#5
0
 public Adapter(OldElectricitySystem adaptee)
 {
     this._adaptee = adaptee;
 }
示例#6
0
文件: Adapter.cs 项目: olko/MySpace
 public Adapter(OldElectricitySystem adaptee)
 {
     _adaptee = adaptee;
 }