示例#1
0
        public void TestConstruction()
        {
            var settings = new LogLevelSettings();

            settings.ForegroundColor.Should().Be(Colors.Black);
            settings.BackgroundColor.Should().Be(Colors.Transparent);
        }
示例#2
0
        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
        }
示例#3
0
        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);
        }
示例#4
0
        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);
                }
            }
        }
示例#5
0
        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);
 }