mirror of
https://github.com/wismna/ModernKeePass.git
synced 2025-10-03 23:50:18 -04:00
Drag drop finally works
WIP item background New Donate page stub Renamed some classes as services
This commit is contained in:
28
ModernKeePass/Services/SettingsService.cs
Normal file
28
ModernKeePass/Services/SettingsService.cs
Normal file
@@ -0,0 +1,28 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user