private CommandOutletContent GetHandledContent(string name, CommandOutletColor color, HandledEventArgs args) { var content = CommandOutletContent.Create(color, name) .Append(CommandOutletColor.DarkGray, "(") .Append(CommandOutletColor.DarkCyan, args.Context.EventId) .Append(CommandOutletColor.DarkGray, ".") .Append(CommandOutletColor.DarkBlue, (args.Context.Index + 1).ToString()) .Append(CommandOutletColor.DarkGray, "): ") .Append(CommandOutletColor.DarkYellow, $"[{args.Context.ScheduleId}] ") .Append(CommandOutletColor.DarkCyan, args.Handler.ToString()) .Append(CommandOutletColor.DarkGray, "@") .Append(CommandOutletColor.DarkMagenta, args.Context.Trigger.ToString()); if (!string.IsNullOrWhiteSpace(args.Context.Trigger.Description)) { content.Append(CommandOutletColor.DarkGray, "(" + args.Context.Trigger.Description + ")"); } if (args.Context.Failure.HasValue) { var failure = args.Context.Failure.Value; //为重试信息添加起始标记 content.Append(CommandOutletColor.Gray, " {"); if (failure.Count > 0 && failure.Timestamp.HasValue) { content.Append(CommandOutletColor.DarkYellow, "#"); content.Append(CommandOutletColor.DarkRed, failure.Count.ToString()); content.Append(CommandOutletColor.DarkYellow, "#"); content.Append(CommandOutletColor.DarkGray, " ("); content.Append(CommandOutletColor.DarkRed, failure.Timestamp.HasValue ? failure.Timestamp.ToString() : Properties.Resources.Scheduler_Retry_NoTimestamp); content.Append(CommandOutletColor.DarkGray, ")"); } if (failure.Expiration.HasValue) { content.Append(CommandOutletColor.Red, " < "); content.Append(CommandOutletColor.DarkGray, "("); content.Append(CommandOutletColor.DarkMagenta, failure.Expiration.HasValue ? failure.Expiration.ToString() : Properties.Resources.Scheduler_Retry_NoExpiration); content.Append(CommandOutletColor.DarkGray, ")"); } //为重试信息添加结束标记 content.Append(CommandOutletColor.Gray, "}"); } if (args.Exception != null) { //设置名称内容端的文本颜色为红色 content.First.Color = CommandOutletColor.Red; content.AppendLine() .Append(this.GetExceptionContent(args.Exception)); } return(content); }
/// <summary> /// 追加一个指定颜色和文本的内容段。 /// </summary> /// <param name="color">指定的内容文本颜色。</param> /// <param name="text">指定的内容文本。</param> /// <returns>返回当前内容段。</returns> public CommandOutletContent AppendLine(CommandOutletColor color, string text) { if (string.IsNullOrEmpty(text)) { return(this.AppendLine()); } else { return(this.Append(color, text + Environment.NewLine)); } }
public void WriteLine(CommandOutletColor foregroundColor, string format, params object[] args) { lock (_syncRoot) { var originalColor = this.ForegroundColor; this.ForegroundColor = foregroundColor; Console.WriteLine(format, args); this.ForegroundColor = originalColor; } }
public void WriteLine(CommandOutletColor foregroundColor, string text) { lock (_syncRoot) { var originalColor = this.ForegroundColor; this.ForegroundColor = foregroundColor; Console.WriteLine(text); this.ForegroundColor = originalColor; } }
public void WriteLine(CommandOutletColor foregroundColor, object value) { lock (_syncRoot) { var originalColor = this.ForegroundColor; this.ForegroundColor = foregroundColor; Console.WriteLine(value); this.ForegroundColor = originalColor; } }
/// <summary> /// 新增一个指定颜色和文本的内容段,并作为当前内容链的首部返回。 /// </summary> /// <param name="color">指定的内容文本颜色。</param> /// <param name="text">指定的内容文本。</param> /// <returns>返回新增的首部内容段。</returns> public CommandOutletContent Prepend(CommandOutletColor color, string text) { if (string.IsNullOrEmpty(text)) { return(this); } //获取当前内容链的首段 var first = this.First; //在首段插入一个片段,并返回该新的首段 return(first.BeforeCore(color, text)); }
private ConsoleColor ConvertColor(CommandOutletColor color, ConsoleColor defaultColor) { ConsoleColor result; if (Enum.TryParse <ConsoleColor>(color.ToString(), out result)) { return(result); } else { return(defaultColor); } }
/// <summary> /// 追加一个指定颜色和文本的内容段。 /// </summary> /// <param name="color">指定的内容文本颜色。</param> /// <param name="text">指定的内容文本。</param> /// <returns>返回当前内容段。</returns> public CommandOutletContent Append(CommandOutletColor color, string text) { if (string.IsNullOrEmpty(text)) { return(this); } //获取当前内容链的最末尾段 var last = this.Last; //在最末段追加一个片段 last.AfterCore(color, text); //返回当前内容段 return(this); }
public void WriteLine(CommandOutletColor color, string format, params object[] args) { }
public void WriteLine(CommandOutletColor color, string format, params object[] args) { }
public void WriteLine(CommandOutletColor color, string text) { }
public void WriteLine(CommandOutletColor color, object value) { }
/// <summary> /// 创建一个指定颜色和文本的新内容段。 /// </summary> /// <param name="color">指定的内容文本颜色。</param> /// <param name="text">指定的内容文本。</param> /// <returns>返回新创建的内容段。</returns> public static CommandOutletContent Create(CommandOutletColor color, string text) { return(new CommandOutletContent(null, text, color)); }
/// <summary> /// 在当前内容段前面插入一个指定颜色和文本的内容段。 /// </summary> /// <param name="color">指定的内容文本颜色。</param> /// <param name="text">指定的内容文本。</param> /// <returns>返回新插入的内容段。</returns> public CommandOutletContent Before(CommandOutletColor color, string text) { return(this.BeforeCore(color, text)); }
public void WriteLine(CommandOutletColor color, string text) { }
public void WriteLine(CommandOutletColor foregroundColor, CommandOutletContent content) { this.WriteContent(content, true, foregroundColor); }
public void WriteLine(CommandOutletColor color, CommandOutletContent content) { }
/// <summary> /// 在当前内容段后面添加一个指定颜色和文本的内容段。 /// </summary> /// <param name="color">指定的内容文本颜色。</param> /// <param name="text">指定的内容文本。</param> /// <returns>返回新添加的内容段。</returns> public CommandOutletContent After(CommandOutletColor color, string text) { return(this.AfterCore(color, text)); }
public void WriteLine(CommandOutletColor color, object value) { }