mirror of
https://github.com/wismna/ModernKeePass.git
synced 2025-10-03 23:50:18 -04:00
WIP Clean Architecture
Windows 8.1 App Uses keepasslib v2.44 (temporarily)
This commit is contained in:
31
ModernKeePass.Infrastucture.12/UWP/UwpSettingsClient.cs
Normal file
31
ModernKeePass.Infrastucture.12/UWP/UwpSettingsClient.cs
Normal file
@@ -0,0 +1,31 @@
|
||||
using System;
|
||||
using Windows.Foundation.Collections;
|
||||
using Windows.Storage;
|
||||
using ModernKeePass.Application.Common.Interfaces;
|
||||
|
||||
namespace ModernKeePass.Infrastructure.UWP
|
||||
{
|
||||
public class UwpSettingsClient : ISettingsProxy
|
||||
{
|
||||
private readonly IPropertySet _values = ApplicationData.Current.LocalSettings.Values;
|
||||
|
||||
public T GetSetting<T>(string property, T defaultValue = default)
|
||||
{
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user