コード例 #1
0
        static void Main(string[] args)
        {
            Traveller traveller = new Traveller();

            Car car = new Car();

            Camel    camel      = new Camel();
            ICarMove cammelMove = new AdapterCarToCamel(camel);

            traveller.Move(car);
            traveller.Move(cammelMove);
        }
コード例 #2
0
        private static void Main(string[] args)
        {
            // academic example
            var client = new Client();

            client.Request(new Adapter(new Adaptee()));

            Console.WriteLine("\n");

            // imaginary but more helpful example:
            // - imagine you have a driver who tries cross the desert,
            // - he drives a car
            // - but at some places it is impossible to drive a car
            // - so he should drive a camel
            var traveler = new Traveller();

            traveler.Drive(new Car());
            traveler.Drive(new TransportAdapter(new Camel()));
        }