public void TestConstruction() { var settings = new LogLevelSettings(); settings.ForegroundColor.Should().Be(Colors.Black); settings.BackgroundColor.Should().Be(Colors.Transparent); }
public static void ConfigureLogLevelSettings(this IServiceCollection services, IConfiguration configuration) { var settings = new LogLevelSettings(); configuration.Bind("Logging:LogLevel", settings); services.AddSingleton <LogLevelSettings>(settings); // add singleton for DI }
public void TestRoundtrip([ValueSource(nameof(SomeColors))] Color foregroundColor, [ValueSource(nameof(SomeColors))] Color backgroundColor) { var settings = new LogLevelSettings { ForegroundColor = foregroundColor, BackgroundColor = backgroundColor }; var actualSettings = Restore(Save(settings)); actualSettings.ForegroundColor.Should().Be(foregroundColor); actualSettings.BackgroundColor.Should().Be(backgroundColor); }
private static LogLevelSettings Restore(string file) { using (var stream = new MemoryStream(Encoding.UTF8.GetBytes(file))) { using (var reader = XmlReader.Create(stream)) { reader.MoveToContent(); var settings = new LogLevelSettings(); settings.Restore(reader); return(settings); } } }
private static string Save(LogLevelSettings logViewerSettings) { using (var stream = new MemoryStream()) { using (var writer = XmlWriter.Create(stream)) { writer.WriteStartDocument(); writer.WriteStartElement("Test"); logViewerSettings.Save(writer); writer.WriteEndElement(); writer.WriteEndDocument(); } return(Encoding.UTF8.GetString(stream.ToArray())); } }
public LogLevelSettingsViewModel(IApplicationSettings settings, LogLevelSettings logLevelSettings) { _settings = settings; _logLevelSettings = logLevelSettings; }
public LoggingService(IApplicationDbContext context, ILogger <LoggingService> logger, LogLevelSettings settings) { _context = context; _logger = logger; _logLevel = (LogLevel)Enum.Parse(typeof(LogLevel), settings.Default, true); }