Пример #1
0
        static void Main(string[] args)
        {
            SetConsoleOutputCP(65001);
            SetConsoleCP(65001);
            Console.OutputEncoding = System.Text.Encoding.UTF8;

            Console.WriteLine("=====================");

            Console.WriteLine("Client1 - gọi chưa có adapter sử dụng đúng Target của hệ thống ví dụ: chỉ cần insert dữ liệu vào mssql");
            var client1 = new Client(target: new Target());

            client1.MakeRequest();

            Console.WriteLine("=====================");

            Console.WriteLine("Client2 - gọi cần có adapter sử dụng, ví dụ: cần insert vào Oracle và MariaDB");
            var client2 = new Client(target: new Adapter());

            client2.MakeRequest();


            Console.WriteLine("=====================");
            Console.WriteLine("Enter để kết thúc");
            Console.ReadLine();
        }
Пример #2
0
		public static void Main (string[] args)
		{
			Target t = new Adapter (); //instiante Target interface with Adapter
			Client c = new Client (t); //put the instance of Target interface into client
			c.MakeRequest ();          //now client can use method B from Adaptee through Adapter
			Adapter a = new Adapter (); // we can also directly put the instance of Adapter into client
			Client cc = new Client (a);
			cc.MakeRequest ();
		}
        public static void Main(string[] args)
        {
            Target t = new Adapter();              //instiante Target interface with Adapter
            Client c = new Client(t);              //put the instance of Target interface into client

            c.MakeRequest();                       //now client can use method B from Adaptee through Adapter
            Adapter a  = new Adapter();            // we can also directly put the instance of Adapter into client
            Client  cc = new Client(a);

            cc.MakeRequest();
        }