private async Task EditWhiteListAsync(string text, CancellationToken token) { MessageTextBox.Text = string.Join(Environment.NewLine, _whiteList); while (!token.IsCancellationRequested) { var whiteList = MessageTextBox.Text .Split(new[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries).ToList(); var current = QQChat.Find().FirstOrDefault(); if (current is null) { await Task.Delay(200); } else if (whiteList.Find(x => x == current.Name) == null) { whiteList.Add(current.Name); MessageTextBox.Text = string.Join(Environment.NewLine, whiteList); await Task.Delay(200, token); } else { await Task.Delay(200); } } _whiteList.Clear(); _whiteList.AddRange(MessageTextBox.Text.Split(new[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries)); DefaultConfiguration.FromFile("configs.txt")["WhiteList"] = string.Join("\n", _whiteList); MessageTextBox.Text = ""; }
private void OnLoaded(object sender, RoutedEventArgs e) { _current = QQChat.Find().FirstOrDefault(); GroupNameTextBlock.Text = _current?.Name; var whiteList = DefaultConfiguration.FromFile("configs.txt")["WhiteList"].ToString() .Split(new[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries); _whiteList.AddRange(whiteList); }
public void FromFile() { "从文件获取一个默认的配置,可以得到配置。".Test(() => { // Arrange var coin = TestUtil.GetTempFile("configs.sim.coin"); // Act var configs = DefaultConfiguration.FromFile(coin.FullName); // Assert var value = configs["Foo"]; Assert.IsFalse(value.HasValue); }); }