Files
modernkeepass/ModernKeePass/Services/SettingsService.cs
BONNEVILLE Geoffroy f2731c49dd Drag drop finally works
WIP item background
New Donate page stub
Renamed some classes as services
2017-11-29 19:13:38 +01:00

29 lines
794 B
C#

using System;
using Windows.Storage;
namespace ModernKeePass.Services
{
public class SettingsService
{
public static T GetSetting<T>(string property)
{
try
{
return (T)Convert.ChangeType(ApplicationData.Current.LocalSettings.Values[property], typeof(T));
}
catch (InvalidCastException)
{
return default(T);
}
}
public static void PutSetting<T>(string property, T value)
{
var localSettings = ApplicationData.Current.LocalSettings;
if (localSettings.Values.ContainsKey(property))
localSettings.Values[property] = value;
else localSettings.Values.Add(property, value);
}
}
}