当前位置: 首页 > news >正文

建设网站怎么收费标准网站婚庆模板

建设网站怎么收费标准,网站婚庆模板,4399游戏官网入口,wordpress发号系统前言 命令模式的关键通过将请求封装成一个对象#xff0c;使命令的发送者和接收者解耦。这种方式能更方便地添加新的命令#xff0c;如执行命令的排队、延迟、撤销和重做等操作。 代码 #region 基础的命令模式 //命令#xff08;抽象类#xff09; public abstract class …前言 命令模式的关键通过将请求封装成一个对象使命令的发送者和接收者解耦。这种方式能更方便地添加新的命令如执行命令的排队、延迟、撤销和重做等操作。 代码 #region 基础的命令模式 //命令抽象类 public abstract class Command {public abstract void Execute(); } //发送命令 public class SendCommand : Command {private Receiver receiver;public SendCommand(Receiver receiver){this.receiver receiver;}public override void Execute(){receiver.Execute();} } //接收命令 public class Receiver {public void Execute(){Console.WriteLine(receiver execute the command...);} } //调用者命令 public class Invoker {private Command command;public void SetCommand(Command command){this.command command;}public void ExecuteCommand(){command.Execute();} } #endregion#region 添加新的命令模式 //新命令 public class NewCommand : Command {private NewReceiver newReceiver;public NewCommand(NewReceiver newReceiver){this.newReceiver newReceiver;}public override void Execute(){newReceiver.Execute();} } //使用新接收者 public class NewReceiver {public void Execute(){Console.WriteLine(new reveiver execute the newCommand...);} }#endregion#region 命令的请求的排队和延迟执行 //命令执行者 public class CommandInvoker {private ListCommand commandQueue new ListCommand();public void AddCommand(Command command){commandQueue.Add(command);}public void ExecuteCommands(){foreach (Command command in commandQueue){command.Execute();}commandQueue.Clear();}public void DelayExecute(Command command,int delay){Console.WriteLine($等待开始....时间{delay}ms);new Thread(() {Console.WriteLine($延时执行开始);Thread.Sleep(delay);command.Execute();Console.WriteLine($finish time:{Environment.NewLine}{DateTime.Now.ToString(HH:mm:ss fff)});Console.WriteLine($延时执行完毕...);}).Start();} } #endregion#region 命令撤销和重做操作 public interface ICommand {void Execute();void Undo(); }public class HistoryCommand : ICommand {private HistoryReceiver historyReceiver;public HistoryCommand(HistoryReceiver historyReceiver){this.historyReceiver historyReceiver;}public void Execute(){historyReceiver.Execute();}public void Undo(){historyReceiver.UndoExecute();} }public class HistoryReceiver {public void Execute(){Console.WriteLine(history receiver executes the command...);}public void UndoExecute(){Console.WriteLine(history receiver undoes the command...);} } public class HistoryInvoker {private StackICommand commandStack new StackICommand();public void ExecuteCommand(ICommand command){command.Execute();commandStack.Push(command);}public void Undo(){if (commandStack.Count 0){ICommand command commandStack.Pop();Console.WriteLine(command Undo);command.Undo();}else{Console.WriteLine(No commands to undo.);}}public void Redo(){if (commandStack.Count0){ICommand command commandStack.Peek();Console.WriteLine(command Redo);command.Execute();}else{Console.WriteLine(No commands to redo.);}} }/** 行为型模式Behavioral Pattern* 命令模型Command Pattern*/internal class Program{static void Main(string[] args){//命令模式简单实现Receiver receiver new Receiver();Command sendCommand new SendCommand(receiver);Invoker invoker new Invoker();invoker.SetCommand(sendCommand);invoker.ExecuteCommand();Console.WriteLine(添加新命令------------------------------------);// 命令模式添加新命令NewReceiver newReceiver new NewReceiver();Command newCommand new NewCommand(newReceiver);invoker.SetCommand(newCommand);invoker.ExecuteCommand();Console.WriteLine(请求队列------------------------------------);//命令模式请求队列Receiver receiver1 new Receiver();Command command1 new SendCommand(receiver1);Command command2 new SendCommand(receiver1);CommandInvoker commandInvoker new CommandInvoker();commandInvoker.AddCommand(command1);commandInvoker.AddCommand(command2);commandInvoker.ExecuteCommands();Console.WriteLine(延时执行------------------------------------);Console.WriteLine(${DateTime.Now.ToString(HH:mm:ss fff)});//命令模式延时执行commandInvoker.DelayExecute(command1,1000);Console.WriteLine(准备撤销重做------------------------------------);HistoryReceiver historyReceiver new HistoryReceiver();ICommand command3 new HistoryCommand(historyReceiver);ICommand command4 new HistoryCommand(historyReceiver);HistoryInvoker historyInvoker new HistoryInvoker();historyInvoker.ExecuteCommand(command3);historyInvoker.ExecuteCommand(command4);Console.WriteLine(执行撤销重做------------------------------------);//撤销最后一个命令historyInvoker.Undo();historyInvoker.Undo();//重做最后一个撤销命令historyInvoker.Redo();Console.WriteLine(END------------------------------------);Console.ReadLine();}} #endregion运行结果
http://www.dnsts.com.cn/news/266808.html

相关文章:

  • 网站后台登录界面腾讯云wordpress建站
  • 昆明城乡和住房建设局网站华夏网站建设
  • Django可以做门户网站吗无锡网站推广经理
  • 宿迁 网站制作wordpress添加前台漂亮注册页面
  • 做网站需要多少职务单页网站怎么做竞价
  • wordpress淘宝客主题网络优化工具
  • wordpress社交游戏免费seo优化工具
  • 开发网站的技术路线公司介绍ppt制作
  • 导购网站如何做淘宝客wordpress不允许评论
  • 网站开发实训基本要求免费云主机官网
  • 手机网站微信代码运营推广计划怎么写
  • aws的efs可以做网站的什么做小程序的平台
  • 松山湖做网站推荐武进网站建设
  • 章丘网站定制河北廊坊做网站
  • 果洛wap网站建设比较好动漫制作技术专业要会画画吗
  • 做仿站如何修改网站管理权限精准营销的典型案例
  • 网站静态首页模板潮州seo建站
  • 没有经验可以做网站编辑吗中国建筑模板十大名牌
  • 网站域名怎么做变更郑州建设局网站
  • 深圳网站设计服务商英文seo推广
  • 烟台网站排名优化价格上海知名网站推广
  • 网站keywords重复解决方法陕西有哪些公司是网站建设
  • 北京正邦设计seo咨询茂名
  • 徐州网站建设方案咨询廊坊网站建设方案托管
  • 网站设计与网页制作培训二维码图片制作
  • 如何做企业网站php京网站制作公司
  • 网站开发人员招聘要求十大后悔专业排行榜
  • 网站建设托管预算清单关于网站建设的案例分析
  • 温州做企业网站淘宝网站是谁做的好处
  • 乐山智顶网站建设网站网站制作开发需要哪些技术