public Command(string name, string description, string formatOfArgs, Command.CommandFunction function) { Name = name; Description = description; FormatOfArgs = formatOfArgs; commandFunction = new CommandFunction(function); CommandHandler.AddCommand(this); }
/// <summary> /// 接收处理过程 /// </summary> /// <param name="receiveCount"></param> protected override void ReceiveProcess(int receiveCount) { _databuffer.AddBuffer(_buffer, receiveCount); //将收到的数据添加到缓存器中 while (_databuffer.GetData(out _socketData)) //取出一条完整数据 { _commandHandler.AddCommand(_socketData); } }
public static void LoadCommands(Assembly assembly, string fileName) { var commandType = typeof(ICommandable); List <Type> commands = assembly.GetTypes().Where(x => commandType.IsAssignableFrom(x)).ToList(); foreach (Type cType in commands) { ICommandable cmd = (ICommandable)Activator.CreateInstance(cType); bool canAdd = CommandHandler.AddCommand(cmd); if (canAdd) { Debug.Log(string.Format("Command {0} from {1} added successfully", cmd.handle, fileName)); } else { Debug.LogError(string.Format("Command {0} from {1} failed", cmd.handle, fileName)); } } }
private void CreateCommands() { commands.AddCommand(CommandID.scan, GetComponent <ScanCommand>()); commands.AddCommand(CommandID.help, GetComponent <HelpCommand>()); commands.AddCommand(CommandID.checkForFirewall, GetComponent <CheckFirewallCommand>()); commands.AddCommand(CommandID.connect, GetComponent <ConnectCommand>()); commands.AddCommand(CommandID.disconnect, GetComponent <DisconnectCommand>()); commands.AddCommand(CommandID.ls, GetComponent <lsCommand>()); commands.AddCommand(CommandID.attackFirewall, GetComponent <AttackFirewallCommand>()); commands.AddCommand(CommandID.instantiateKeylogger, GetComponent <KeylogCommand>()); commands.AddCommand(CommandID.startKeylogger, GetComponent <KeylogStartCommand>()); commands.AddCommand(CommandID.exit, GetComponent <ExitCommand>()); commands.AddCommand(CommandID.clear, GetComponent <ClearCommand>()); commands.AddCommand(CommandID.python, GetComponent <PythonCommand>()); commands.AddCommand(CommandID.transfer, GetComponent <TransferCommand>()); commands.AddCommand(CommandID.tjoep, GetComponent <TjoepCommand>()); commands.AddCommand(CommandID.shutdown, GetComponent <ShutdownCommand>()); }