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);
        }
 private static void Execute(ProductReceiver product, ModifyPriceInvoker modifyPrice, IProductCommand productCommand)
 {
     modifyPrice.SetCommand(productCommand);
     modifyPrice.Invoke();
 }
Пример #3
0
 public ProductCommand(ProductReceiver product, PriceAction priceAction, int amount)
 {
     _productReceiver = product;
     _priceAction     = priceAction;
     _amount          = amount;
 }