コード例 #1
0
        static void MainABC(string[] args)
        {
            var modifyPrice = new ModifyPriceInvoker();

            var product = new ProductReceiver("Phone", 500);

            // The client will create the command object
            Execute(product, modifyPrice, new ProductCommand(product, PriceAction.Increase, 100));

            Execute(product, modifyPrice, new ProductCommand(product, PriceAction.Increase, 50));
            Execute(product, modifyPrice, new ProductCommand(product, PriceAction.Decrease, 25));
            Console.WriteLine(product);
        }
コード例 #2
0
 private static void Execute(ProductReceiver product, ModifyPriceInvoker modifyPrice, IProductCommand productCommand)
 {
     modifyPrice.SetCommand(productCommand);
     modifyPrice.Invoke();
 }