Example #1
0
        public static void Main(string[] args)
        {
            var adaptee = new Adaptee {
                Name = "FirstObject"
            };
            var target1 = new Target1 {
                Name = "SecondObject"
            };
            var target2 = new Target2 {
                Name = "ThirdObject"
            };

            var adapter1 = new Adapter(adaptee);
            var adapter2 = new Adapter(target1);
            var adapter3 = new Adapter(target2);

            Console.WriteLine(adapter1.Request("Adapter 1"));
            Console.WriteLine(adapter2.Request("Adapter 2"));
            Console.WriteLine(adapter3.Request("Adapter 3"));
        }
Example #2
0
 public Adapter(Adaptee adaptee)
 {
     this.Request =
         delegate(string key) { return(String.Concat("Request: ", AdapteeMethod(), key, Splitter, adaptee.Name)); };
 }