private void EvalInputString(string inputString) { inputString = inputString.Trim(); if (string.IsNullOrEmpty(inputString)) { LogMessage(ConsoleMessage.Debug(string.Empty)); return; } _history.Add(inputString); LogMessage(ConsoleMessage.Debug(inputString)); var input = new List <string>(inputString.Split(new [] { ' ' }, System.StringSplitOptions.RemoveEmptyEntries)); input = input.Select(low => low.ToLower()).ToList(); var cmd = input[0]; if (CommandController.Contains(cmd)) { CommandController[cmd].Execute(input.ToArray()) .ObserveOnMainThread() .Subscribe(r => LogMessage(ConsoleMessage.Info(r))); } else { LogMessage(ConsoleMessage.Info(string.Format("*** Unknown Command: {0} ***", cmd))); } }
private ConsoleMessage ToLogMessage(RecordType type, string category, string text, Exception exception) { switch (type) { case RecordType.Error: return(ConsoleMessage.Error(String.Format("[{0}] {1}:{2}. Exception: {3}", type, category, text, exception))); case RecordType.Warn: return(ConsoleMessage.Warning(String.Format("[{0}] {1}:{2}", type, category, text))); case RecordType.Info: var lines = text.Trim('\n').Split('\n'); var output = new StringBuilder(); output.Append(String.Format("[{0}] {1}:", type, category)); for (var i = 0; i < lines.Length; i++) { output.AppendFormat("{0}{1}", lines[i], i != lines.Length - 1 ? "\n" : ""); } return(ConsoleMessage.Info(output.ToString())); default: return(ConsoleMessage.Debug(String.Format("[{0}] {1}: {2}", type, category, text))); } }