public CommandWrapper(CommandDelegate del) { if (del == null) { throw new ArgumentNullException ("del"); } this.d = del; }
public Command(CommandDelegate cmd, params string[] names) { if (names == null || names.Length < 1) throw new NotSupportedException(); permission = null; Names = new List<string>(names); command = cmd; }
public bool Register(string Cmd, CommandDelegate Func) { if (!Cmds.ContainsKey(Cmd)) Cmds.Add(Cmd, Func); else return false; return true; }
/// <summary> /// Add a command to be executed in parallel. /// </summary> /// <param name="command"> /// The command to execute. Should be non-null. /// </param> /// <exception cref="System.ArgumentNullException"></exception> public void Add(CommandDelegate command) { if (command == null) { throw new System.ArgumentNullException("command"); } CommandQueue queue = new CommandQueue(); queue.Enqueue(command); _queues.AddLast(queue); }
/// <summary> /// Add a command to those which can be invoked from the console. /// </summary> /// <param name = "command">The string that will make the command execute</param> /// <param name = "commandHelp">The message that will show the user how to use the command</param> /// <param name = "info">Any information about how the command works or what it does</param> /// <param name = "fn"></param> public void AddCommand(string command, string commandHelp, string infomessage, CommandDelegate fn) { CommandInfo info = new CommandInfo{ command = command, commandHelp = commandHelp, info = infomessage, fn = new List<CommandDelegate> {fn} }; tree.AddCommand(info); }
public void SchumixRegisterHandler(string code, CommandDelegate method, CommandPermission permission = CommandPermission.Normal) { if(sIgnoreCommand.IsIgnore(code)) return; if(CommandMethodMap.ContainsKey(code.ToLower())) CommandMethodMap[code.ToLower()].Method += method; else CommandMethodMap.Add(code.ToLower(), new CommandMethod(method, permission)); }
public SkypeClient() { InitializeComponent(); UM_SkypeControlAPIDiscover = Platform.RegisterWindowMessage(Constants.SkypeControlAPIDiscover); UM_SkypeControlAPIAttach = Platform.RegisterWindowMessage(Constants.SkypeControlAPIAttach); commandDelegate += Command; CreateHandle(); }
public static void RegisterCommandHandler(string command, CommandDelegate handler) { try { handlers.Add(command, handler); } catch (ArgumentException) { Debug.Log("An element with Key = " + command + " already exists."); } }
/// <summary> /// Add a command to those which can be invoked from the console. /// </summary> /// <param name="command">The string that will make the command execute</param> /// <param name="commandHelp">The message that will show the user how to use the command</param> /// <param name="infomessage">Any information about how the command works or what it does</param> /// <param name="fn"></param> /// <param name="requiresAScene">Whether this command requires a scene to be fired</param> /// <param name="fireOnceForAllScenes">Whether this command will only be executed once if there is no current scene</param> public void AddCommand (string command, string commandHelp, string infomessage, CommandDelegate fn, bool requiresAScene, bool fireOnceForAllScenes) { CommandInfo info = new CommandInfo { command = command, commandHelp = commandHelp, info = infomessage, fireOnceForAllScenes = fireOnceForAllScenes, requiresAScene = requiresAScene, fn = new List<CommandDelegate> { fn } }; tree.AddCommand (info); }
public Command(CommandDelegate cmd, params string[] names) { if (cmd == null) throw new ArgumentNullException("cmd"); if (names == null || names.Length < 1) throw new ArgumentException("names"); AllowServer = true; CommandDelegate = cmd; DoLog = true; HelpText = "No help available."; Names = new List<string>(names); Permissions = new List<string>(); }
/// <summary> /// Creates instance of EJDB. /// </summary> /// <param name="library"></param> public Database(Library library) { var libraryHandle = library.LibraryHandle; DatabaseHandle = new DatabaseHandle(libraryHandle); Library = library; _openDatabase = libraryHandle.GetUnmanagedDelegate<OpenDatabaseDelegate>(); _closeDatabase = libraryHandle.GetUnmanagedDelegate<CloseDatabaseDelegate>(); _isOpen = libraryHandle.GetUnmanagedDelegate<IsOpenDelegate>(); _getErrorCode = libraryHandle.GetUnmanagedDelegate<GetErrorCodeDelegate>(); _getMetadata = libraryHandle.GetUnmanagedDelegate<GetMetaDelegate>(); _command = libraryHandle.GetUnmanagedDelegate<CommandDelegate>(); _sync = libraryHandle.GetUnmanagedDelegate<SyncDelegate>(); }
public ProxyFrame(string[] args) { bool externalPlugin = false; this.args = args; ProxyConfig proxyConfig = new ProxyConfig("SLProxy", "Austin Jennings / Andrew Ortman", args); proxy = new Proxy(proxyConfig); // add delegates for login proxy.SetLoginRequestDelegate(new XmlRpcRequestDelegate(LoginRequest)); proxy.SetLoginResponseDelegate(new XmlRpcResponseDelegate(LoginResponse)); // add a delegate for outgoing chat proxy.AddDelegate(PacketType.ChatFromViewer, Direction.Outgoing, new PacketDelegate(ChatFromViewerOut)); // handle command line arguments foreach (string arg in args) if (arg == "--log-login") logLogin = true; else if (arg.Substring(0, 2) == "--") { int ipos = arg.IndexOf("="); if (ipos != -1) { string sw = arg.Substring(0, ipos); string val = arg.Substring(ipos + 1); Console.WriteLine("arg '" + sw + "' val '" + val + "'"); if (sw == "--load") { externalPlugin = true; LoadPlugin(val); } } } commandDelegates["/load"] = new CommandDelegate(CmdLoad); if (!externalPlugin) { ProxyPlugin analyst = new Analyst(this); analyst.Init(); } }
/// <summary> /// A Condition command allows branching behaviour. After a condition evaluates to <c>true</c> /// then onTrue will be evaluated until it finishes. Otherise onFalse will be evaluated, (if it /// isn't null). When nested in a Repeat command, conditions will be re-evaluated once for every /// repeat. /// </summary> /// <param name="condition"> /// The condition to evaluate. Must be non-null. /// </param> /// <param name="onTrue"> /// The command to execute if condition evaluates to true. Must be non-null. /// </param> /// <param name="onFalse"> /// The command to execute if condition evaluates to false. /// </param> /// <exception cref="System.ArgumentNullException"></exception> public static CommandDelegate Condition(CommandCondition condition, CommandDelegate onTrue, CommandDelegate onFalse = null) { CheckArgumentNonNull(condition, "condition"); CheckArgumentNonNull(onTrue, "onTrue"); CommandDelegate result = onFalse; return Sequence( Commands.Do( () => { result = onFalse; if (condition()) { result = onTrue; } }), (ref double deltaTime) => { if (result != null) { return result(ref deltaTime); } return true; } ); }
public DelegateCommand(CommandDelegate execute) : this(execute, null) { }
/// <summary> /// Call this from a region module to add a command to the OpenSim console. /// </summary> /// <param name="mod"></param> /// <param name="command"></param> /// <param name="shorthelp"></param> /// <param name="longhelp"></param> /// <param name="descriptivehelp"></param> /// <param name="callback"></param> public void AddCommand( object mod, string command, string shorthelp, string longhelp, string descriptivehelp, CommandDelegate callback) { if (MainConsole.Instance == null) { return; } string modulename = String.Empty; bool shared = false; if (mod != null) { if (mod is IRegionModule) { IRegionModule module = (IRegionModule)mod; modulename = module.Name; shared = module.IsSharedModule; } else if (mod is IRegionModuleBase) { IRegionModuleBase module = (IRegionModuleBase)mod; modulename = module.Name; shared = mod is ISharedRegionModule; } else { throw new Exception("AddCommand module parameter must be IRegionModule or IRegionModuleBase"); } } MainConsole.Instance.Commands.AddCommand( modulename, shared, command, shorthelp, longhelp, descriptivehelp, callback); }
public static void QueryCommand(CommandDelegate dlgQueryCommand) { if (p == null) { return; } if (p.HasExited) { Trace.WriteLine("TS Server は未起動"); return; } isDataAnalyzed = false; ClearDefinitionResult(); ClearReferenceResult(); var pos = Hm.Edit.CursorPos; var lineno = pos.LineNo; var column = pos.Column; if (lineno < 0 || column < 0) { return; } var winFilePath = Hm.Edit.FilePath; if (winFilePath == null) { Hm.Macro.Var["#RTN_noname"] = 1; winFilePath = GetWinTempFilePath(); } var winFilename = System.IO.Path.GetFileName(winFilePath); // tsserver用にUri形式にする Uri u = new Uri(winFilePath); var urlFilePath = u.AbsolutePath; OpenFileMessage(urlFilePath); var strTotalText = Hm.Edit.TotalText; try { var winTempPath = GetWinTempFilePath(); WriteWinTempFilePath(strTotalText); // tsserverが受け付けるuri形式に Uri uTmp = new Uri(winTempPath); var urlTempFilePath = uTmp.AbsolutePath; // リロード ReloadFileMessage(urlFilePath, urlTempFilePath); dlgQueryCommand(urlFilePath, lineno, column + 1); int iSafetyCnt = 0; while (true) { if (iSafetyCnt > 100) { System.Windows.Forms.MessageBox.Show("待ち時間エラー"); break; } if (isDataAnalyzed) { break; } System.Threading.Thread.Sleep(50); } } catch (Exception ex) { Trace.WriteLine(ex.Message); } }
public DelegateCommand(CommandDelegate execute, Func <bool> canExecute) { _execute = execute; _canExecute = canExecute; }
public SignCommand(int coolDown, List <string> permissions, CommandDelegate cmd, params string[] names) : base(permissions, cmd, names) { _cooldown = coolDown; }
/// <summary> /// Call this from a region module to add a command to the OpenSim console. /// </summary> /// <param name="mod"></param> /// <param name="command"></param> /// <param name="shorthelp"></param> /// <param name="longhelp"></param> /// <param name="descriptivehelp"></param> /// <param name="callback"></param> public void AddCommand(IRegionModuleBase module, string command, string shorthelp, string longhelp, string descriptivehelp, CommandDelegate callback) { string moduleName = ""; if (module != null) { moduleName = module.Name; } AddCommand(moduleName, module, command, shorthelp, longhelp, descriptivehelp, callback); }
// private List<string> CollectHelp(Dictionary<string, object> dict) // { // List<string> result = new List<string>(); // // foreach (KeyValuePair<string, object> kvp in dict) // { // if (kvp.Value is Dictionary<string, Object>) // { // result.AddRange(CollectHelp((Dictionary<string, Object>)kvp.Value)); // } // else // { // if (((CommandInfo)kvp.Value).long_help != String.Empty) // result.Add(((CommandInfo)kvp.Value).help_text+" - "+ // ((CommandInfo)kvp.Value).long_help); // } // } // return result; // } /// <summary> /// Add a command to those which can be invoked from the console. /// </summary> /// <param name="module"></param> /// <param name="command"></param> /// <param name="help"></param> /// <param name="longhelp"></param> /// <param name="fn"></param> public void AddCommand(string module, bool shared, string command, string help, string longhelp, CommandDelegate fn) { AddCommand(module, shared, command, help, longhelp, String.Empty, fn); }
public Command(string permissionneeded, CommandDelegate cmd, params string[] names) : this(cmd, names) { Permission = permissionneeded; }
public ConsoleCommand(string command, CommandDelegate action, string help = "") { Command = command; Action = action; Help = help; }
public ConsoleCommand(string command, CommandDelegate action, bool elevated, string help = "") : this(command, action, help) { Elevated = elevated; }
public DelegateCommand(string name, CommandDelegate <TClientSession, TPackageInfo> execution) { Name = name; m_Execution = execution; }
public void AddCommand(string cmd, CommandDelegate deleg) { commandDelegates[cmd] = deleg; }
public Command(string name, CommandDelegate act, object obj) { _name = name; action = act; MemoryObject = obj; }
public void AddCommand(string module, bool shared, string command, string help, string longhelp, string descriptivehelp, CommandDelegate fn) {}
/// <summary> /// Add a command to those which can be invoked from the console. /// </summary> /// <param name="module"></param> /// <param name="command"></param> /// <param name="help"></param> /// <param name="longhelp"></param> /// <param name="descriptivehelp"></param> /// <param name="fn"></param> public void AddCommand(string module, bool shared, string command, string help, string longhelp, string descriptivehelp, CommandDelegate fn) { string[] parts = Parser.Parse(command); Dictionary <string, Object> current = tree; foreach (string part in parts) { if (current.ContainsKey(part)) { if (current[part] is Dictionary <string, Object> ) { current = (Dictionary <string, Object>)current[part]; } else { return; } } else { current[part] = new Dictionary <string, Object>(); current = (Dictionary <string, Object>)current[part]; } } CommandInfo info; if (current.ContainsKey(String.Empty)) { info = (CommandInfo)current[String.Empty]; if (!info.shared && !info.fn.Contains(fn)) { info.fn.Add(fn); } return; } info = new CommandInfo(); info.module = module; info.shared = shared; info.help_text = help; info.long_help = longhelp; info.descriptive_help = descriptivehelp; info.fn = new List <CommandDelegate>(); info.fn.Add(fn); current[String.Empty] = info; // Now add command to modules dictionary lock (m_modulesCommands) { List <CommandInfo> commands; if (m_modulesCommands.ContainsKey(module)) { commands = m_modulesCommands[module]; } else { commands = new List <CommandInfo>(); m_modulesCommands[module] = commands; } // m_log.DebugFormat("[COMMAND CONSOLE]: Adding to category {0} command {1}", module, command); commands.Add(info); } }
public void FromXml(XmlElement root, CommandDelegate fn) { CommandInfo help = (CommandInfo)((Dictionary<string, object>)tree["help"])[String.Empty]; ((Dictionary<string, object>)tree["help"]).Remove(string.Empty); if (((Dictionary<string, object>)tree["help"]).Count == 0) tree.Remove("help"); CommandInfo quit = (CommandInfo)((Dictionary<string, object>)tree["quit"])[String.Empty]; ((Dictionary<string, object>)tree["quit"]).Remove(string.Empty); if (((Dictionary<string, object>)tree["quit"]).Count == 0) tree.Remove("quit"); tree.Clear(); ReadTreeLevel(tree, root, fn); if (!tree.ContainsKey("help")) tree["help"] = (object) new Dictionary<string, object>(); ((Dictionary<string, object>)tree["help"])[String.Empty] = help; if (!tree.ContainsKey("quit")) tree["quit"] = (object) new Dictionary<string, object>(); ((Dictionary<string, object>)tree["quit"])[String.Empty] = quit; }
protected override async Task Decorate(TestCommand command, CancellationToken cancellationToken, CommandDelegate <TestCommand, Unit> continuation) => await continuation.Invoke(command, cancellationToken);
/// <summary> /// Add a command to those which can be invoked from the console. /// </summary> /// <param name = "command">The string that will make the command execute</param> /// <param name = "commandHelp">The message that will show the user how to use the command</param> /// <param name = "info">Any information about how the command works or what it does</param> /// <param name = "fn"></param> public void AddCommand(string command, string commandHelp, string infomessage, CommandDelegate fn) { CommandInfo info = new CommandInfo { command = command, commandHelp = commandHelp, info = infomessage, fn = new List <CommandDelegate> { fn } }; tree.AddCommand(info); }
public async Task requires_continuation() { continuation = null; await Assert.ThrowsAsync <ArgumentNullException>(nameof( continuation ), invoke); }
/// <summary> /// Call this from a region module to add a command to the OpenSim console. /// </summary> /// <param name="mod"> /// The use of IRegionModuleBase is a cheap trick to get a different method signature, /// though all new modules should be using interfaces descended from IRegionModuleBase anyway. /// </param> /// <param name="category"> /// Category of the command. This is the section under which it will appear when the user asks for help /// </param> /// <param name="command"></param> /// <param name="shorthelp"></param> /// <param name="longhelp"></param> /// <param name="callback"></param> public void AddCommand( string category, IRegionModuleBase module, string command, string shorthelp, string longhelp, CommandDelegate callback) { AddCommand(category, module, command, shorthelp, longhelp, string.Empty, callback); }
public void AddCommand(string module, bool shared, string command, string help, string longhelp, CommandDelegate fn) { m_commands.AddCommand(module, shared, command, help, longhelp, fn); }
public Command(CommandDelegate commandDelegate) : this() { _commandDelegate = commandDelegate; }
public override bool CanSeeCommand(TSPlayer sender, CommandDelegate <TSPlayer> command) { var permissions = command.GetCustomAttribute <CommandPermissions>(); return(permissions == null || permissions.Permissions.Any(perm => sender.Group.HasPermission(perm))); }
public static void Main(string[] args) { Console.ForegroundColor = ConsoleColor.Green; Console.WriteLine("Welcome to LibClassicBot beta."); Console.WriteLine("Below is a list of commands and how to use them"); Console.WriteLine(".position - Announces the position of the bot in the map."); Console.WriteLine(".allow <user> - Adds a user to a list of allowed operators."); Console.WriteLine(".disallow <user> - Removes a user from the list of allowed operators."); Console.WriteLine(".say <message> - Makes the bot send the specified message."); Console.WriteLine(".players - Lists the visibile players to the bot in the current map."); Console.WriteLine(".move <x,y,z> - Moves the bot to the specified coordinates."); Console.WriteLine(".place <x,y,z> - Attempts to place a block at the specified coordinates."); Console.WriteLine(".haspaid <username> - Announces if a user has paid or not."); Console.WriteLine(".cuboid <blocktype> - Cuboids between two points."); Console.WriteLine(".cuboidh <blocktype> - Draws a hollow cuboid between two points."); Console.WriteLine(".cuboidw <blocktype> - Draws a wireframe between two points."); Console.WriteLine(".ellipsoid <blocktype> - Draws an ellipsoid between two points."); Console.WriteLine(".pyramid <blocktype> - Draws an upwards pyramid between two points."); Console.WriteLine(".follow <username> - Follows player. (Case sensitive)"); Console.WriteLine(".speed <number> - The number of blocks to place per second."); Console.WriteLine(".abort - Stops the currently running draw operation."); Console.WriteLine(".drawimg 0 <filename> - Attempts to draw the specified image."); Console.ResetColor(); Console.WriteLine("Enter the username to be used by the bot: (Minecraft account)"); string username = Console.ReadLine(); Console.WriteLine("Enter the password to be used by the bot: (Minecraft account)"); string password = Console.ReadLine(); Console.WriteLine("Enter the address of the server to connect to: "); string hash = Console.ReadLine(); if (!hash.StartsWith("http")) { if (hash.StartsWith("minecraft")) { hash = "http://" + hash; } else { hash = "http://minecraft.net/classic/play/" + hash; } } ClassicBot Bot1 = new ClassicBot(username, password, hash); ConsoleLogger logger = new ConsoleLogger(); Bot1.RegisterLogger(logger); FileLogger file = new FileLogger(); Bot1.RegisterLogger(file); Bot1.Events.ChatMessage += Bot1_ChatMessage; Bot1.Events.PlayerMoved += Bot1_PlayerMoved; Bot1.Events.RemoteSessionStarted += RemoteSessionStarted; Bot1.Events.RemoteUserLoggedIn += RemoteUserLoggedIn; Bot1.Events.RemoteSessionEnded += RemoteSessionEnded; #if !MONO Bot1.Events.MapLoaded += Bot1_MapLoaded; Bot1.Events.ConfigLoading += delegate { Console.WriteLine("Loading"); }; #endif #region Plugins CommandDelegate MazeCommand = delegate(string Line) { Maze maze = new Maze(); maze.originalchatline = Line; Bot1.SetDrawer(Line, maze, 2); }; Bot1.RegisteredCommands.Add("maze", MazeCommand); CommandDelegate DrawCommand = delegate(string Line) { DrawImage img = new DrawImage(); img.originalchatline = Line; Bot1.SetDrawer(Line, img, 2); }; Bot1.RegisteredCommands.Add("drawimg", DrawCommand); CommandDelegate PositionCommand = delegate(string Line) { Bot1.SendMessagePacket(String.Format("Positon in world is at {0},{1},{2}.", Bot1.X, Bot1.Y, Bot1.Z)); }; Bot1.RegisteredCommands.Add("position", PositionCommand); CommandDelegate AddOpCommand = delegate(string Line) { string[] full = Bot1.GetMessage(Line).Split(new char[] { ' ' }, 2); Bot1.AddOperator(full[1]); Bot1.SendMessagePacket("Allowed user: "******"allow", AddOpCommand); CommandDelegate RemoveOpCommand = delegate(string Line) { string[] full = Bot1.GetMessage(Line).Split(new char[] { ' ' }, 2); Bot1.RemoveOperator(full[1]); Bot1.SendMessagePacket("Disallowed user: "******"disallow", RemoveOpCommand); CommandDelegate ListOpsCommand = delegate(string Line) { string[] names = Bot1.Users.ToArray(); Bot1.SendLongChat(String.Join(", ", names)); }; Bot1.RegisteredCommands.Add("ops", ListOpsCommand); CommandDelegate SayCommand = delegate(string Line) { string[] full = Bot1.GetMessage(Line).Split(new char[] { ' ' }, 2); Bot1.SendMessagePacket(full[1]); }; Bot1.RegisteredCommands.Add("say", SayCommand); CommandDelegate PlayersCommand = delegate(string Line) { List <string> Names = new List <string>(); foreach (Player player in Bot1.Players.Values) { Names.Add(player.Name); } string output = String.Join(",", Names.ToArray()); Bot1.SendLongChat("Players in current world: " + output); }; Bot1.RegisteredCommands.Add("players", PlayersCommand); CommandDelegate MoveCommand = delegate(string Line) { string[] full = Bot1.GetMessage(Line).Split(new char[] { ' ' }, 2); string[] coords = full[1].Split(new char[] { ',' }, 3); Bot1.SendPositionPacket(Int16.Parse(coords[0]), Int16.Parse(coords[1]), Int16.Parse(coords[2])); }; Bot1.RegisteredCommands.Add("move", MoveCommand); CommandDelegate PlaceCommand = delegate(string Line) { string[] full = Bot1.GetMessage(Line).Split(new char[] { ' ' }, 2); string[] coords = full[1].Split(new char[] { ',' }, 4); Bot1.SendBlockPacket(Int16.Parse(coords[0]), Int16.Parse(coords[1]), Int16.Parse(coords[2]), 1, Byte.Parse(coords[3])); }; Bot1.RegisteredCommands.Add("place", PlaceCommand); CommandDelegate HasPaidCommand = delegate(string Line) { string[] full = Bot1.GetMessage(Line).Split(new char[] { ' ' }, 2); try { bool paid; WebClient client = new WebClient(); string response = client.DownloadString("https://minecraft.net/haspaid.jsp?user="******"minecraft.net returned: " + (int)response.StatusCode + " " + response.StatusCode.ToString()); } } else { Bot1.SendMessagePacket("Unhandled error occured: " + ex.Status.ToString()); } } }; Bot1.RegisteredCommands.Add("haspaid", HasPaidCommand); CommandDelegate FollowCommand = delegate(string Line) { string[] full = Bot1.GetMessage(Line).Split(new char[] { ' ' }, 2); personfollowed = full[1]; Bot1.SendMessagePacket("Following user " + full[1]); }; Bot1.RegisteredCommands.Add("follow", FollowCommand); CommandDelegate CuboidCommand = delegate(string Line) { Cuboid cuboid = new Cuboid(); Bot1.SetDrawer(Line, cuboid, 2); }; Bot1.RegisteredCommands.Add("cuboid", CuboidCommand); CommandDelegate PyramidCommand = delegate(string Line) { Pyramid pyramid = new Pyramid(); Bot1.SetDrawer(Line, pyramid, 2); }; Bot1.RegisteredCommands.Add("pyramid", PyramidCommand); CommandDelegate AbortCommand = delegate(string Line) { Bot1.CancelDrawer(); personfollowed = String.Empty; }; Bot1.RegisteredCommands.Add("abort", AbortCommand); CommandDelegate SpeedCommand = delegate(string Line) { string[] full = Bot1.GetMessage(Line).Split(new char[] { ' ' }, 2); Bot1.CuboidSleepTime = 1000 / Int32.Parse(full[1]); }; Bot1.RegisteredCommands.Add("speed", SpeedCommand); CommandDelegate EllipsoidCommand = delegate(string Line) { Ellipsoid ellipsoid = new Ellipsoid(); Bot1.SetDrawer(Line, ellipsoid, 2); }; Bot1.RegisteredCommands.Add("ellipsoid", EllipsoidCommand); CommandDelegate CuboidHCommand = delegate(string Line) { CuboidHollow cuboidh = new CuboidHollow(); Bot1.SetDrawer(Line, cuboidh, 2); }; Bot1.RegisteredCommands.Add("cuboidh", CuboidHCommand); CommandDelegate CuboidWCommand = delegate(string Line) { CuboidWireframe cuboidw = new CuboidWireframe(); Bot1.SetDrawer(Line, cuboidw, 2); }; Bot1.RegisteredCommands.Add("cuboidw", CuboidWCommand); CommandDelegate LineCommand = delegate(string Line) { Line line = new Line(); Bot1.SetDrawer(Line, line, 2); }; Bot1.RegisteredCommands.Add("line", LineCommand); CommandDelegate IgnoreCommand = delegate(string Line) { string[] full = Bot1.GetMessage(Line).Split(new char[] { ' ' }, 2); Bot1.IgnoredUserList.Add(full[1]); Bot1.SendMessagePacket("Ignored user: "******"ignore", IgnoreCommand); CommandDelegate UnIgnoreCommand = delegate(string Line) { string[] full = Bot1.GetMessage(Line).Split(new char[] { ' ' }, 2); Bot1.IgnoredUserList.Remove(full[1]); Bot1.SendMessagePacket("Unignored user: "******"unignore", UnIgnoreCommand); /*CommandDelegate TestPosCommand = delegate(string Line) * { //Ain't no way to stop it. Uncomment with severe caution. * new System.Threading.Thread( * delegate() { * Random rnd = new Random(); * while(true){ * * int rndval1 = rnd.Next(0, 360); * byte newpitch = Extensions.DegreesToYaw(rndval1); * int rndval2 = rnd.Next(0, 360); * byte newyaw = Extensions.DegreesToYaw(rndval2); * Bot1.SendPositionPacket(Bot1.X, Bot1.Y, Bot1.Z, newyaw, newpitch); * System.Threading.Thread.Sleep(10); * } * }).Start(); * }; * Bot1.RegisteredCommands.Add("testpos", TestPosCommand);*/ #endregion StaticBot1 = Bot1; Bot1.Start(false); loop: { string response = Console.ReadLine(); Bot1.SendMessagePacket(response); goto loop; } }
public Command(string permissions, CommandDelegate cmd, params string[] names) : this(cmd, names) { Permissions = new List<string> { permissions }; }
/// <summary> /// Add a command to those which can be invoked from the console. /// </summary> /// <param name="command">The string that will make the command execute</param> /// <param name="commandHelp">The message that will show the user how to use the command</param> /// <param name="infomessage">Any information about how the command works or what it does</param> /// <param name="fn"></param> /// <param name="requiresAScene">Whether this command requires a scene to be fired</param> /// <param name="fireOnceForAllScenes">Whether this command will only be executed once if there is no current scene</param> public void AddCommand(string command, string commandHelp, string infomessage, CommandDelegate fn, bool requiresAScene, bool fireOnceForAllScenes) { CommandInfo info = new CommandInfo { command = command, commandHelp = commandHelp, info = infomessage, fireOnceForAllScenes = fireOnceForAllScenes, requiresAScene = requiresAScene, fn = new List <CommandDelegate> { fn } }; tree.AddCommand(info); }
public Command(string cmdname, string permissionneeded, CommandDelegate cmd) { Name = cmdname; permission = permissionneeded; command = cmd; }
public async Task InvokeAsync(CommandContext context, CommandDelegate next) { context.NotNull(nameof(context)); if (context.Result.HasContent()) { await next(context); return; } if (context.Command.HasContent()) { var result = await ExecutePreconditionsForContextAsync(context); if (result.Success) { await next(context); } else { context.Result = result; } return; } var matchesFeature = context.Features.Get <ICommandMatchesFeature>(); if (matchesFeature.HasNoContent() || matchesFeature.CommandMatches.HasNoContent()) { throw new InvalidOperationException($"Can't get command matches from feature: {nameof(ICommandMatchesFeature)}."); } var matches = matchesFeature.CommandMatches; var fails = new Dictionary <ICommand, IResult>(); var bestMatches = new List <ICommandMatch>(); foreach (var match in matches) { var command = match.Command; var result = await ExecutePreconditionsAsync(command, context); if (result.Success) { bestMatches.Add(match); } else { fails.Add(command, result); } } if (bestMatches.HasNoContent()) { _logger.LogInformation("All matched commands returned fail for input count."); context.Result = MiddlewareUtils.GetErrorResult(fails); return; } matchesFeature.CommandMatches = bestMatches; await next(context); }
/// <summary> /// Call this from a region module to add a command to the OpenSim console. /// </summary> /// <param name="mod"></param> /// <param name="command"></param> /// <param name="shorthelp"></param> /// <param name="longhelp"></param> /// <param name="callback"></param> public void AddCommand(object mod, string command, string shorthelp, string longhelp, CommandDelegate callback) { AddCommand(mod, command, shorthelp, longhelp, string.Empty, callback); }
public Command(List<string> permissions, CommandDelegate cmd, params string[] names) : this(cmd, names) { Permissions = permissions; }
public Command(string name, T state, CommandDelegate f) { this.name = name; this.state = state; this.command = f; }
public CommandMethod(CommandDelegate method, CommandPermission permission = CommandPermission.Normal) { Method = method; Permission = permission; }
private bool DebugMode = false; //System.Diagnostics.Debugger.IsAttached; #endregion Fields #region Methods /// <summary> Adds a command to the Queue of commands to be executed. </summary> /// <param name="Command">The anonymous delegate to execute.</param> /// <param name="Line">The chatline which triggered the execution, used for arguements.</param> public void EnqueueCommand( CommandDelegate command, string Line ) { if( !CommandsThreadStarted ) return; CommandQueue.Enqueue( new InternalCommand( command, Line ) ); }
public void FromXml(XmlElement root, CommandDelegate fn) {}
public GriderProxyFrame(string[] args) { //bool externalPlugin = false; this.args = args; GriderProxyConfig proxyConfig = new GriderProxyConfig("GridSurferProxy", "Crista Lopes / Diva", args); proxy = new GriderProxy(proxyConfig); // add delegates for login proxy.SetLoginRequestDelegate(new XmlRpcRequestDelegate(LoginRequest)); proxy.SetLoginResponseDelegate(new XmlRpcResponseDelegate(LoginResponse)); // add a delegate for outgoing chat proxy.AddDelegate(PacketType.ChatFromViewer, Direction.Outgoing, new PacketDelegate(ChatFromViewerOut)); // handle command line arguments foreach (string arg in args) if (arg == "--log-login") logLogin = true; else if (arg.Substring(0, 2) == "--") { int ipos = arg.IndexOf("="); if (ipos != -1) { string sw = arg.Substring(0, ipos); string val = arg.Substring(ipos + 1); Console.WriteLine("arg '" + sw + "' val '" + val + "'"); if (sw == "--load") { //externalPlugin = true; LoadPlugin(val); } } } commandDelegates["/load"] = new CommandDelegate(CmdLoad); }
/// <summary> /// Add a command to those which can be invoked from the console. /// </summary> /// <param name="module"></param> /// <param name="command"></param> /// <param name="help"></param> /// <param name="longhelp"></param> /// <param name="descriptivehelp"></param> /// <param name="fn"></param> public void AddCommand(string module, bool shared, string command, string help, string longhelp, string descriptivehelp, CommandDelegate fn) { string[] parts = Parser.Parse(command); Dictionary<string, Object> current = tree; foreach (string part in parts) { if (current.ContainsKey(part)) { if (current[part] is Dictionary<string, Object>) current = (Dictionary<string, Object>)current[part]; else return; } else { current[part] = new Dictionary<string, Object>(); current = (Dictionary<string, Object>)current[part]; } } CommandInfo info; if (current.ContainsKey(String.Empty)) { info = (CommandInfo)current[String.Empty]; if (!info.shared && !info.fn.Contains(fn)) info.fn.Add(fn); return; } info = new CommandInfo(); info.module = module; info.shared = shared; info.help_text = help; info.long_help = longhelp; info.descriptive_help = descriptivehelp; info.fn = new List<CommandDelegate>(); info.fn.Add(fn); current[String.Empty] = info; // Now add command to modules dictionary lock (m_modulesCommands) { List<CommandInfo> commands; if (m_modulesCommands.ContainsKey(module)) { commands = m_modulesCommands[module]; } else { commands = new List<CommandInfo>(); m_modulesCommands[module] = commands; } // m_log.DebugFormat("[COMMAND CONSOLE]: Adding to category {0} command {1}", module, command); commands.Add(info); } }
/// <summary> /// Add a command to those which can be invoked from the console. /// </summary> /// <param name="module"></param> /// <param name="command"></param> /// <param name="help"></param> /// <param name="longhelp"></param> /// <param name="fn"></param> public void AddCommand(string module, bool shared, string command, string help, string longhelp, CommandDelegate fn) { AddCommand(module, shared, command, help, longhelp, String.Empty, fn); }
private void ReadTreeLevel(Dictionary<string, object> level, XmlNode node, CommandDelegate fn) { Dictionary<string, object> next; string name; XmlNodeList nodeL = node.ChildNodes; XmlNodeList cmdL; CommandInfo c; foreach (XmlNode part in nodeL) { switch (part.Name) { case "Level": name = ((XmlElement)part).GetAttribute("Name"); next = new Dictionary<string, object>(); level[name] = next; ReadTreeLevel(next, part, fn); break; case "Command": cmdL = part.ChildNodes; c = new CommandInfo(); foreach (XmlNode cmdPart in cmdL) { switch (cmdPart.Name) { case "Module": c.module = cmdPart.InnerText; break; case "Shared": c.shared = Convert.ToBoolean(cmdPart.InnerText); break; case "HelpText": c.help_text = cmdPart.InnerText; break; case "LongHelp": c.long_help = cmdPart.InnerText; break; case "Description": c.descriptive_help = cmdPart.InnerText; break; } } c.fn = new List<CommandDelegate>(); c.fn.Add(fn); level[String.Empty] = c; break; } } }
public bool Add(string commandName, string commandDescription, string commandFullDescription, CommandDelegate <TResult> onExecuteCommand, params ArgumentString[] arguments) => Add(commandName, commandDescription, commandFullDescription, (executionArguments, context) => ((onExecuteCommand == null) ? DefaultParseReturnValue : onExecuteCommand(executionArguments)), arguments);
internal InternalCommand( CommandDelegate Command, string Line ) { command = Command; line = Line; }
public Command(string name, CommandDelegate f) { this.name = name; this.state = default(T); this.command = f; }
public void AddRule(ParserSequence sequence, CommandDelegate command, string example) { AddRule(new CommandParserRule(sequence, command, example)); }
public void AddRule(ParserSequence sequence, CommandDelegate command) { AddRule(new CommandParserRule(sequence, command, null)); }
/// <summary> /// Add a command to those which can be invoked from the console. /// </summary> /// <param name="module"></param> /// <param name="command"></param> /// <param name="help"></param> /// <param name="longhelp"></param> /// <param name="descriptivehelp"></param> /// <param name="fn"></param> public void AddCommand(string module, bool shared, string command, string help, string longhelp, string descriptivehelp, CommandDelegate fn) { string[] parts = Parser.Parse(command); Dictionary<string, Object> current = tree; foreach (string s in parts) { if (current.ContainsKey(s)) { if (current[s] is Dictionary<string, Object>) { current = (Dictionary<string, Object>)current[s]; } else return; } else { current[s] = new Dictionary<string, Object>(); current = (Dictionary<string, Object>)current[s]; } } CommandInfo info; if (current.ContainsKey(String.Empty)) { info = (CommandInfo)current[String.Empty]; if (!info.shared && !info.fn.Contains(fn)) info.fn.Add(fn); return; } info = new CommandInfo(); info.module = module; info.shared = shared; info.help_text = help; info.long_help = longhelp; info.descriptive_help = descriptivehelp; info.fn = new List<CommandDelegate>(); info.fn.Add(fn); current[String.Empty] = info; }
public bool Add(string commandName, string commandDescription, string commandFullDescription, CommandDelegate <TResult, TContext> onExecuteCommand, params ArgumentString[] arguments) { bool ret = false; Command <TResult, TContext> command = Command <TResult, TContext> .New(commandName, commandDescription, commandFullDescription, onExecuteCommand, arguments); if (commands.Add(command)) { commandLookup.Add(command.Name, command); ret = true; } return(ret); }