Beispiel #1
0
		public static void RegisterCommand(string name, CommandDefinition definition)
		{
			var fullName = name + definition.ParametersCount;
			if (Functions.ContainsKey(fullName))
			{
				return;
			}
			Functions.TryAdd(fullName, definition);
		}
Beispiel #2
0
		private void ExecuteCommand(CommandDefinition cmd, List<NodeCsToken> tokens)
		{
			try
			{
				var type = cmd.Action.GetType();
				if (type == typeof(Action))
				{
					((Action)cmd.Action)();
				}
				else if (type == typeof(Action<string>))
				{
					((Action<string>)cmd.Action)(tokens[1].Value);
				}
				else if (type == typeof(Action<string, string>))
				{
					((Action<string, string>)cmd.Action)(tokens[1].Value, tokens[2].Value);
				}
				else if (type == typeof(Action<string, string,string>))
				{
					((Action<string, string, string>)cmd.Action)(tokens[1].Value, tokens[2].Value, tokens[3].Value);
				}
				else
				{
					throw new Exception("Unsupported command");
				}
			}
			catch (Exception ex)
			{
				_lastException = ex;
				Shared.NodeRoot.CWriteLine("Error executing command:");
				Shared.NodeRoot.CWriteLine(ex.Message);
			}
		}
Beispiel #3
0
		public void RegisterCommand(string name, CommandDefinition definition)
		{

		}