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)); }
private static void Execute(Product product, ModifyPrice modifyPrice, ICommand productCommand) { modifyPrice.SetCommand(productCommand); modifyPrice.Invoke(); }