static void Main(string[] args)
        {
            // Example
            var vectorObjects = new List <VectorObject> {
                new VectorRectangle(1, 1, 2, 2),
                new VectorRectangle(3, 3, 6, 6)
            };

            foreach (var vo in vectorObjects)
            {
                foreach (var line in vo)
                {
                    var adapter = new LineToPointAdapter(line);
                    adapter.ForEach(Draw.Point);
                }
            }

            Console.WriteLine();
            Console.WriteLine();

            // SimpleSample
            var           classManager  = new ClassManager();
            IClassManager IClassManager = new ClassAdapter(classManager);

            Console.WriteLine("Original Xml Output\n" + classManager.GetAllStudents());
            Console.WriteLine("Adapter Json Output\n" + IClassManager.GetAllStudents());
        }
예제 #2
0
        static void Main(string[] args)
        {
            Console.WriteLine("Hello World!");

            ITarget classAdapter = new ClassAdapter();

            classAdapter.Charging();

            Console.ReadLine();
        }
예제 #3
0
        static void Main(string[] args)
        {
            ITarget target = new ClassAdapter();

            target.DoSomeThingClientNeed();
            ObjectAdapter adapter = new ObjectAdapter();

            adapter.DoSomeThingClientNeed();
            Console.ReadLine();
        }
예제 #4
0
        static void Main(string[] args)
        {
            Adaptee adaptee = new Adaptee();
            ITarget target  = new ObjectAdapter(adaptee);

            Console.WriteLine("Adaptee interface is incompatible with the client.");
            Console.WriteLine("But with adapter client can call it's method.");

            Console.WriteLine(target.GetRequest());

            ITarget target2 = new ClassAdapter();

            Console.WriteLine(target2.GetRequest());
        }
예제 #5
0
        static void Main(string[] args)
        {
            var adaptee = new Adaptee();

            //Delegation을 이용한 Adapter
            var adapter = new Adapter(adaptee);

            adapter.Request();

            //Inheritance를 이용한 Adapter
            //SpecificRequest()를 호출하지 않도록 주의합니다.
            var classAdapter = new ClassAdapter();

            classAdapter.Request();
        }