seb-win-refactoring/SafeExamBrowser.Configuration/ConfigurationData/DataMapping/GeneralDataMapper.cs

37 lines
963 B
C#
Raw Normal View History

/*
* Copyright (c) 2024 ETH Zürich, IT Services
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
using SafeExamBrowser.Settings;
using SafeExamBrowser.Settings.Logging;
2019-12-20 10:03:47 +01:00
namespace SafeExamBrowser.Configuration.ConfigurationData.DataMapping
{
2019-12-20 10:03:47 +01:00
internal class GeneralDataMapper : BaseDataMapper
{
2019-12-20 10:03:47 +01:00
internal override void Map(string key, object value, AppSettings settings)
{
2019-12-20 10:03:47 +01:00
switch (key)
{
2019-12-20 10:03:47 +01:00
case Keys.General.LogLevel:
MapLogLevel(settings, value);
break;
}
}
private void MapLogLevel(AppSettings settings, object value)
{
const int ERROR = 0, WARNING = 1, INFO = 2;
if (value is int level)
{
settings.LogLevel = level == ERROR ? LogLevel.Error : (level == WARNING ? LogLevel.Warning : (level == INFO ? LogLevel.Info : LogLevel.Debug));
}
}
}
}