mirror of
https://github.com/wismna/ModernKeePass.git
synced 2025-10-04 16:10:16 -04:00

Added a new settings page to allow auto-save or not App now resumes correctly from suspend Settings service now allows getting default values Removed french special characters from metadata Code cleanup
32 lines
895 B
C#
32 lines
895 B
C#
using System;
|
|
using Windows.Foundation.Collections;
|
|
using Windows.Storage;
|
|
using ModernKeePass.Interfaces;
|
|
|
|
namespace ModernKeePass.Services
|
|
{
|
|
public class SettingsService : SingletonServiceBase<SettingsService>, ISettingsService
|
|
{
|
|
private readonly IPropertySet _values = ApplicationData.Current.LocalSettings.Values;
|
|
|
|
public T GetSetting<T>(string property, T defaultValue = default(T))
|
|
{
|
|
try
|
|
{
|
|
return (T)Convert.ChangeType(_values[property], typeof(T));
|
|
}
|
|
catch (InvalidCastException)
|
|
{
|
|
return defaultValue;
|
|
}
|
|
}
|
|
|
|
public void PutSetting<T>(string property, T value)
|
|
{
|
|
if (_values.ContainsKey(property))
|
|
_values[property] = value;
|
|
else _values.Add(property, value);
|
|
}
|
|
}
|
|
}
|