From 24b4073616381a12e00dfa6bff9041ad7522ff01 Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Mon, 8 Apr 2019 20:33:52 -0400 Subject: [PATCH] support bool type --- src/Core/Services/PreferencesStorageService.cs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/Core/Services/PreferencesStorageService.cs b/src/Core/Services/PreferencesStorageService.cs index ab6bc82e8..c1deae0ba 100644 --- a/src/Core/Services/PreferencesStorageService.cs +++ b/src/Core/Services/PreferencesStorageService.cs @@ -22,6 +22,11 @@ namespace Bit.Core.Services var val = Xamarin.Essentials.Preferences.Get(formattedKey, default(string)); return Task.FromResult((T)(object)val); } + else if(objType == typeof(bool) || objType == typeof(bool?)) + { + var val = Xamarin.Essentials.Preferences.Get(formattedKey, default(bool)); + return Task.FromResult((T)Convert.ChangeType(val, objType)); + } else if(objType == typeof(int) || objType == typeof(int?)) { var val = Xamarin.Essentials.Preferences.Get(formattedKey, default(int)); @@ -61,6 +66,10 @@ namespace Bit.Core.Services { Xamarin.Essentials.Preferences.Set(formattedKey, obj as string); } + else if(objType == typeof(bool) || objType == typeof(bool?)) + { + Xamarin.Essentials.Preferences.Set(formattedKey, (obj as bool?).Value); + } else if(objType == typeof(int) || objType == typeof(int?)) { Xamarin.Essentials.Preferences.Set(formattedKey, (obj as int?).Value);