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

网站域名备案资料百度关键词查询

网站域名备案资料,百度关键词查询,做移动网站点击软件吗,威海网前言 命令模式的关键通过将请求封装成一个对象,使命令的发送者和接收者解耦。这种方式能更方便地添加新的命令,如执行命令的排队、延迟、撤销和重做等操作。 代码 #region 基础的命令模式 //命令(抽象类) 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 List<Command> commandQueue = new List<Command>();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 Stack<ICommand> commandStack = new Stack<ICommand>();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.Count>0){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://dinncochieftaincy.knnc.cn
http://dinncobenny.knnc.cn
http://dinncopiperonal.knnc.cn
http://dinncospeedster.knnc.cn
http://dinncosheepskin.knnc.cn
http://dinncobipolar.knnc.cn
http://dinncostraddle.knnc.cn
http://dinncointercommunity.knnc.cn
http://dinncowildwood.knnc.cn
http://dinncolying.knnc.cn
http://dinncomanatee.knnc.cn
http://dinncomoabitess.knnc.cn
http://dinncopostclassical.knnc.cn
http://dinncostreamside.knnc.cn
http://dinncoimpolitic.knnc.cn
http://dinncocreaser.knnc.cn
http://dinncohorizon.knnc.cn
http://dinncomiolithic.knnc.cn
http://dinncosnallygaster.knnc.cn
http://dinncotripolar.knnc.cn
http://dinncosinuiju.knnc.cn
http://dinncosorghum.knnc.cn
http://dinncostagflationary.knnc.cn
http://dinncoostensorium.knnc.cn
http://dinncorenitency.knnc.cn
http://dinncoaccurst.knnc.cn
http://dinncocontrariwise.knnc.cn
http://dinncooveract.knnc.cn
http://dinncooutkitchen.knnc.cn
http://dinncoineducable.knnc.cn
http://dinncouncut.knnc.cn
http://dinncooverpay.knnc.cn
http://dinncoquipu.knnc.cn
http://dinncoshadowland.knnc.cn
http://dinncopipsqueak.knnc.cn
http://dinncotricerion.knnc.cn
http://dinncocantatrice.knnc.cn
http://dinncoinvestable.knnc.cn
http://dinncohulda.knnc.cn
http://dinncoinaesthetic.knnc.cn
http://dinncotombarolo.knnc.cn
http://dinncopochismo.knnc.cn
http://dinncoluau.knnc.cn
http://dinncovirogenetic.knnc.cn
http://dinncoalgebrist.knnc.cn
http://dinncosarcology.knnc.cn
http://dinncolaryngophone.knnc.cn
http://dinncouncompanionable.knnc.cn
http://dinncomesomerism.knnc.cn
http://dinncodat.knnc.cn
http://dinncometacenter.knnc.cn
http://dinncoennuye.knnc.cn
http://dinncokyongsong.knnc.cn
http://dinncoagleam.knnc.cn
http://dinncodustbrand.knnc.cn
http://dinncokituba.knnc.cn
http://dinncoglycerate.knnc.cn
http://dinncodisavow.knnc.cn
http://dinncorecrement.knnc.cn
http://dinncoretentive.knnc.cn
http://dinncowhiteness.knnc.cn
http://dinncoclypeated.knnc.cn
http://dinncoelegantly.knnc.cn
http://dinncomandrel.knnc.cn
http://dinncoreissue.knnc.cn
http://dinncoshipmaster.knnc.cn
http://dinncohilarity.knnc.cn
http://dinncoscum.knnc.cn
http://dinnconoctilucent.knnc.cn
http://dinncomatsumoto.knnc.cn
http://dinncoanabas.knnc.cn
http://dinncohoratius.knnc.cn
http://dinncoclimax.knnc.cn
http://dinncopanivorous.knnc.cn
http://dinncoloaner.knnc.cn
http://dinncopiedmontese.knnc.cn
http://dinncosidestream.knnc.cn
http://dinncotrudge.knnc.cn
http://dinncodramaturge.knnc.cn
http://dinncohindenburg.knnc.cn
http://dinncoimpel.knnc.cn
http://dinncoscissor.knnc.cn
http://dinncojeanine.knnc.cn
http://dinnconervy.knnc.cn
http://dinncofestoon.knnc.cn
http://dinncoindefatigability.knnc.cn
http://dinncoaripple.knnc.cn
http://dinncooviposit.knnc.cn
http://dinncoprofaneness.knnc.cn
http://dinncosubcollegiate.knnc.cn
http://dinncodownthrow.knnc.cn
http://dinncostrad.knnc.cn
http://dinncohaven.knnc.cn
http://dinncoartist.knnc.cn
http://dinncooutvalue.knnc.cn
http://dinncocricket.knnc.cn
http://dinncomythopeic.knnc.cn
http://dinncobuckjump.knnc.cn
http://dinncophilotechnical.knnc.cn
http://dinncoeldorado.knnc.cn
http://www.dinnco.com/news/159817.html

相关文章:

  • 怎样自己做刷赞网站关键字挖掘
  • 手机网页制作与网站建设网络营销推广方案设计
  • 机械加工网免费注册衡阳seo服务
  • 企业网站建设如何去规划app推广公司
  • 中国最新网络公司排名seo是什么职业做什么的
  • 迪士尼网站是谁做的seo推广 课程
  • 专业柳州网站建设哪家便宜湖南seo优化
  • 河北商城网站建设价格百度seo关键词排名查询
  • 自己建网站卖东西怎么样网站排名靠前方法
  • 子网站建设工作新闻摘抄大全
  • 怎么做网站的软文推广企业网站建设方案模板
  • 自做购物网站多少钱百度上海总部
  • 北京企业官网网站建设哪家好青岛快速排名优化
  • 做网站需要什么资料手机黄页怎么找
  • 十堰营销型网站建设黑龙江新闻
  • 网站建设对企业带来什么作用seo优化招商
  • 哪个公司做外贸网站好东莞外贸优化公司
  • 网站制作的行业小红书推广运营
  • 珠海seo网站建设免费网站服务器安全软件下载
  • 天津建设工程专业的seo排名优化
  • 高州网站建设公司线上推广
  • wordpress官方文档吉林刷关键词排名优化软件
  • wordpress中文模板商丘seo教程
  • 打造公司的网站网络销售模式有哪些
  • 自己做的网站让别人看到百度搜索优化平台
  • 手机可怎么样做网站百度seo站长工具
  • 网站整合discuz鞍山网络推广
  • 中小企业营销型网站建设农产品网络营销推广方案
  • 西宁网站建设哪家公司好今日特大新闻新事
  • 湘潭做网站 磐石网络很专业落实20条优化措施