设计模式之Command
public interface ICommand
{
bool Execute(string command);
}
public class Producer{
static List<ICommand> commands = new List<ICommand>();
public static List<ICommand> produceRequests()
{
if (commands.Count > 0) return commands;
commands.Add(new SkillManager());
return commands;
}
}
public class TcpClient
{
public static object obj = new object();
/// <summary>
/// 客í户§端?命ü令?处鋦理え?
/// </summary>
public void Accept(string command)
{
lock(obj){
List<ICommand> comm = Producer.produceRequests();
for(int i = 0;i<comm.Count;i++){
try{
if(comm[i].Execute(command)) return;
}
catch(Exception e)
{
Console.Write(e);
continue;
}
}
}
}
}
public class SkillManager : ICommand{
public bool Execute(string command){
}
}
浙公网安备 33010602011771号