/// <summary> /// override ToString /// </summary> /// <returns></returns> public String ToString(ConsoleOutputFormat Format) { String MethodHelp = ""; if (Format == ConsoleOutputFormat.JSON) { MethodHelp = String.Format(@"{'Name':'{0}','Arguments':'{1}','Description':'{2}'}", Name, _Arguments, Description); } else if (Format == ConsoleOutputFormat.XML) { MethodHelp = String.Format(@"<Help Name='{0}' Arguments='{1}' Description='{2}' />", Name, _Arguments, Description); } else { String fn = String.Format("[{0}]", String.IsNullOrWhiteSpace(_Arguments) ? " " : _Arguments); MethodHelp = String.Format(" {0}{1}{2}", Name.PadRight(8, ' '), fn.PadRight(24, ' '), Description); } return(MethodHelp); }
public Boolean OutputFormat(String args) { if (String.IsNullOrWhiteSpace(args)) { String ErrorMessage = "参数输入错误,不能为空"; WriteError(ErrorMessage, _OutputFormat, MethodBase.GetCurrentMethod()); return(false); } try { _OutputFormat = Uint_Regex.IsMatch(args) ? (ConsoleOutputFormat)Convert.ToInt32(args) : (ConsoleOutputFormat)Enum.Parse(typeof(ConsoleOutputFormat), args, true); } catch (Exception e) { WriteError(e.Message, _OutputFormat, MethodBase.GetCurrentMethod()); return(false); } return(true); }