static void Main() { var productFactory = new ProductFactory(); Func <Product> funMakePizza = new Func <Product>(productFactory.MakePizza); Func <Product> funMakeToyCar = new Func <Product>(productFactory.MakeToyCar); var wrapFactroy = new WrapFactory(); Box box1 = wrapFactroy.WrapProduct(funMakeToyCar); Box box2 = wrapFactroy.WrapProduct(funMakePizza); Console.WriteLine(box1.Product.Name); Console.WriteLine(box2.Product.Name); }
static void Main(string[] args) { IProductFactory pizzaFactory = new PizzaFactroy(); IProductFactory toyCarFactory = new ToyCarFactory(); var wrapFactory = new WrapFactory(); Box pizzaBox = wrapFactory.WrapProduct(pizzaFactory); Box toyCarBox = wrapFactory.WrapProduct(toyCarFactory); Console.WriteLine(pizzaBox.Product.Name); Console.WriteLine(toyCarBox.Product.Name); }
static void Main() { var productFactory = new ProductFactory(); Func <Product> funcMakePizza = new Func <Product>(productFactory.MakePizza); Func <Product> funcMakeToyCar = new Func <Product>(productFactory.MakeToyCar); var wrapFactory = new WrapFactory(); var logger = new Logger(); Action <Product> logAction = new Action <Product>(logger.Log); Box box1 = wrapFactory.WrapProduct(funcMakePizza, logAction); Box box2 = wrapFactory.WrapProduct(funcMakeToyCar, logAction); Console.WriteLine(box1.Product.Price); Console.WriteLine("Hello,World!"); Console.WriteLine(box2.Product.Price); }