示例#1
0
        public static void Demo()
        {
            ModifyPrice modifyPrice = new ModifyPrice();
            Product     product     = new Product {
                Name = "Phone", Price = 100
            };

            Execute(product, modifyPrice, new ProductCommand(product, PriceAction.Increase));
            Execute(product, modifyPrice, new ProductCommand(product, PriceAction.Decrease));
            Execute(product, modifyPrice, new ProductCommand(product, PriceAction.Decrease));
            Execute(product, modifyPrice, new ProductCommand(product, PriceAction.Increase));
        }
示例#2
0
 private static void Execute(Product product, ModifyPrice modifyPrice, ICommand productCommand)
 {
     modifyPrice.SetCommand(productCommand);
     modifyPrice.Invoke();
 }