DiscordMediaLoader/DML.Core/Classes/Settings.cs

39 lines
1.3 KiB
C#
Raw Normal View History

2017-10-04 11:27:01 +02:00
using System.Diagnostics;
2017-04-16 22:46:29 +02:00
2017-10-04 11:27:01 +02:00
namespace DML.Core.Classes
2017-04-16 22:46:29 +02:00
{
internal class Settings
{
public int Id { get; } = 1; // using always unique ID
public string Email { get; set; }
public string Password { get; set; }
public string LoginToken { get; set; }
public bool UseUserData { get; set; } = false;
public bool SavePassword { get; set; } = false;
public LogLevel ApplicactionLogLevel { get; set; } = LogLevel.Info | LogLevel.Warn | LogLevel.Error;
public string OperatingFolder { get; set; }
2017-04-30 11:06:10 +02:00
public string FileNameScheme { get; set; } = @"%guild%\%channel%\%id%";
public bool SkipExistingFiles { get; set; } = true;
public int ThreadLimit { get; set; } = 50;
2017-04-16 22:46:29 +02:00
internal void Store()
{
Trace("Getting settings collection...");
2017-10-04 11:27:01 +02:00
var settingsDB = DML.Core.Core.Database.GetCollection<Settings>("settings");
2017-04-16 22:46:29 +02:00
Debug("Storing settings to database...");
if (settingsDB.Exists(_setting => _setting.Id == Id))
{
Trace("Updating existing value...");
settingsDB.Update(this);
}
else
{
Trace("Adding new value...");
settingsDB.Insert(this);
}
}
}
}