From c46ec2e074be3fbb79ffd2a6567b709f216ed58a Mon Sep 17 00:00:00 2001 From: Andreas Date: Sun, 7 Apr 2024 19:15:48 +0200 Subject: [PATCH] Update MauiSettingsGeneric.cs --- src/MauiSettings/MauiSettingsGeneric.cs | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/src/MauiSettings/MauiSettingsGeneric.cs b/src/MauiSettings/MauiSettingsGeneric.cs index bf9d4b2..b9fd7b0 100644 --- a/src/MauiSettings/MauiSettingsGeneric.cs +++ b/src/MauiSettings/MauiSettingsGeneric.cs @@ -300,22 +300,22 @@ public static async Task>> ToCo return setting; } - public static Task>> ToSettingsTupleAsync(Expression> value) - => ToSettingsTupleAsync(settings: SettingsObject, value: value); + public static Task>> ToSettingsTupleAsync(Expression> value, string? key = null) + => ToSettingsTupleAsync(settings: SettingsObject, value: value, key: key); - public static async Task>> ToSettingsTupleAsync(object? settings, Expression> value) + public static async Task>> ToSettingsTupleAsync(object? settings, Expression> value, string? key = null) { - MauiSettingsInfo? info = await GetExpressionMetaAsKeyValuePairAsync(settings: settings, value: value); + MauiSettingsInfo? info = await GetExpressionMetaAsKeyValuePairAsync(settings: settings, value: value, key: key); return new(info.Name, new(info.Value, info.SettingsType)); } #endregion #region Encryption - public static Task ExhangeKeyAsync(string newKey, string? oldKey = null) + public static Task ExhangeKeyAsync(string newKey, string? oldKey = null, bool reloadSettings = false) => Task.Run(async delegate { - await LoadSecureSettingsAsync(key: oldKey); + if (reloadSettings) await LoadSecureSettingsAsync(key: oldKey); await SaveSettingsAsync(key: newKey); }); @@ -406,7 +406,10 @@ static async Task GetMetaFromDictionaryAsync(object settings, Dictionary(object settings, Expression