コード例 #1
0
ファイル: Commands.cs プロジェクト: kendarorg/Node.Cs.Old
		public static void RegisterCommand(string name, CommandDefinition definition)
		{
			var fullName = name + definition.ParametersCount;
			if (Functions.ContainsKey(fullName))
			{
				return;
			}
			Functions.TryAdd(fullName, definition);
		}
コード例 #2
0
ファイル: NodeCsParser.cs プロジェクト: kendarorg/Node.Cs.Old
		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);
			}
		}
コード例 #3
0
ファイル: FakeMain.cs プロジェクト: kendarorg/Node.Cs.Old
		public void RegisterCommand(string name, CommandDefinition definition)
		{

		}