public void Clear() { cmd = null; currentParam = 0; InvalidCommandMessage = string.Empty; obj = null; behavior = null; method = null; }
internal object DeserializeMethod(string value, RCDMethodsItem behaviour) { if (behaviour == null) { return(null); } if (behaviour.MethodLookup.ContainsKey(value)) { return((object)behaviour.MethodLookup[value]); } return(null); }
/// <summary> command parser method </summary> internal void ParseCommand(string cmd) { string [] parsedCmd = cmd.Split(' '); int i; string cmdName = parsedCmd[0]; string parameters = ""; for (i = 1; i < parsedCmd.Length; i++) { parameters += parsedCmd[i] + " "; } if (!CacheMethods.ContainsKey(cmdName)) { Manager.RegisterCommand(cmdName, parameters, "Unknown command"); return; } Command command = CacheMethods[cmdName]; if (command.ParamCount != parsedCmd.Length - 1) { Manager.RegisterCommand(cmdName, parameters, "Wrong params count"); return; } int count = command.ParamCount; if (command.HaveLogParam) { count++; } object [] paramsobj = new object[count]; RCDItem item = null; RCDMethodsItem behavior = null; for (i = 0; i < command.ParamCount; i++) { System.Type type = command.GetParamType(i); if (type == typeof(RCDMethodsItem)) { paramsobj[i] = Manager.Serializer.DeserializeMethodItem(parsedCmd[i + i], item); behavior = (RCDMethodsItem)paramsobj[i]; } else if (type == typeof(MethodInfo)) { paramsobj[i] = Manager.Serializer.DeserializeMethod(parsedCmd[i + 1], behavior); } else { paramsobj[i] = Manager.Serializer.Deserialize(command.GetParamType(i), parsedCmd[i + 1]); if (type == typeof(RCDItem)) { item = (RCDItem)paramsobj[i]; } } if (paramsobj[i] == null) { Manager.RegisterCommand(cmdName, parameters, "Wrong params"); return; } } LogMessage log = Manager.RegisterCommand(cmdName, parameters, command.HaveLogParam ? "Waiting" : "Succesfull"); if (command.HaveLogParam) { paramsobj[paramsobj.Length - 1] = log; } Launch(cmdName, paramsobj); Manager.CommandLaunched(log); }