Exemple #1
0
        static void Main(string[] args)
        {
            IProductfactory pf  = new PizzaFactory();
            IProductfactory tf  = new ToyFactory();
            Retailer        rtl = new Retailer();

            Box boxPizza = rtl.SellProduct(pf);
            Box boxToy   = rtl.SellProduct(tf);

            Console.WriteLine(boxPizza.Product.Name);
            Console.WriteLine(boxToy.Product.Name);
        }
Exemple #2
0
        static void Main(string[] args)
        {
            ProductFactory pf  = new ProductFactory();
            Retailer       rtl = new Retailer();

            Func <Product> makepizza = new Func <Product>(pf.MakePizza);
            Func <Product> maketoy   = new Func <Product>(pf.MakeToy);

            Box boxPizza = rtl.SellProduct(makepizza);
            Box boxToy   = rtl.SellProduct(maketoy);

            Console.WriteLine(boxPizza.Product.Name);
            Console.WriteLine(boxToy.Product.Name);
        }
Exemple #3
0
        static void Main(string[] args)
        {
            ProductFactory pf  = new ProductFactory();
            Retailer       rtl = new Retailer();

            Func <Product> makepizza = new Func <Product>(pf.MakePizza);
            Func <Product> maketoy   = new Func <Product>(pf.MakeToy);

            Logger           logger  = new Logger();
            Action <Product> showlog = new Action <Product>(logger.Log);

            Box boxPizza = rtl.SellProduct(makepizza, showlog);
            Box boxToy   = rtl.SellProduct(maketoy, showlog);

            Console.WriteLine(boxPizza.Product.Name);
            Console.WriteLine(boxToy.Product.Name);
        }