public async Task ListAsync() { var items = await this.DataBaseContext.Dispatcher.InvokeAsync(() => { var query = from item in this.DataBaseContext where StringUtility.GlobMany(item.Name, FilterProperties.FilterExpression) select new { item.IsLoaded, item.Name }; return(query.ToArray()); }); var tb = new TerminalStringBuilder(); foreach (var item in items) { if (item.IsLoaded == false) { tb.Foreground = TerminalColor.BrightBlack; tb.AppendLine(item.Name); tb.Foreground = null; } else { tb.AppendLine(item.Name); } } tb.AppendEnd(); this.Out.WriteLine(tb.ToString()); }
protected override string FormatPrompt(string prompt) { if (this.IsCommandMode == false) { return(base.FormatPrompt(prompt)); } else { var postfixPattern = string.Join(string.Empty, postfix.Select(item => $"[{item}]")); var tb = new TerminalStringBuilder(); if (this.commandContext.IsOnline == false) { var match = Regex.Match(prompt, $"(.*)(?<postfix>{postfixPattern})$"); tb.Foreground = TerminalColor.BrightGreen; tb.Append(match.Groups[1].Value); tb.Foreground = null; tb.Append(match.Groups[2].Value); } else { var p1 = prompt.TrimStart(); var p2 = prompt.TrimEnd(); var prefix = prompt.Substring(p1.Length); var postfix = prompt.Substring(p2.Length); var uri = new Uri(prompt.Trim()); tb.Append(prefix); tb.Foreground = TerminalColor.BrightGreen; tb.Append(uri.Scheme); tb.Foreground = null; tb.Append(Uri.SchemeDelimiter); tb.Foreground = TerminalColor.BrightCyan; tb.Append(uri.UserInfo); tb.Foreground = null; tb.Append("@"); tb.Foreground = TerminalColor.BrightCyan; tb.Append(uri.Authority); tb.Foreground = null; tb.Append(uri.LocalPath); tb.Append(postfix); } tb.AppendEnd(); return(tb.ToString()); } }