static void Main(string[] args) { ProductFacoty productFactory = new ProductFacoty(); WrapFactory wrapFactory = new WrapFactory(); Func <Product> func1 = new Func <Product>(productFactory.MakePizza); Func <Product> func2 = new Func <Product>(productFactory.MakeToyCar); Logger logger = new Logger(); Action <Product> action = new Action <Product>(logger.Log); Box box1 = wrapFactory.WrapProduct(func1, action); Box box2 = wrapFactory.WrapProduct(func2, action); Console.WriteLine(box1.Product.Name); Console.WriteLine(box2.Product.Name); IProductFactory pizzaFactory = new PizzaFactory(); IProductFactory toyCarFactory = new ToyCarFactory(); Box box3 = wrapFactory.WrapProduct_2(pizzaFactory); Box box4 = wrapFactory.WrapProduct_2(toyCarFactory); Console.WriteLine(box3.Product.Name); Console.WriteLine(box4.Product.Name); }
static void Main(string[] args) { ProductFacoty productFactory = new ProductFacoty(); WrapFactory wrapFactory = new WrapFactory(); Func<Product> func1 = new Func<Product>(productFactory.MakePizza); Func<Product> func2 = new Func<Product>(productFactory.MakeToyCar); Logger logger = new Logger(); Action<Product> action = new Action<Product>(logger.Log); Box box1 = wrapFactory.WrapProduct(func1, action); Box box2 = wrapFactory.WrapProduct(func2, action); Console.WriteLine(box1.Product.Name); Console.WriteLine(box2.Product.Name); IProductFactory pizzaFactory = new PizzaFactory(); IProductFactory toyCarFactory = new ToyCarFactory(); Box box3 = wrapFactory.WrapProduct_2(pizzaFactory); Box box4 = wrapFactory.WrapProduct_2(toyCarFactory); Console.WriteLine(box3.Product.Name); Console.WriteLine(box4.Product.Name); }