Skip to content

Commit

Permalink
Update MauiSettingsGeneric.cs
Browse files Browse the repository at this point in the history
  • Loading branch information
AndreasReitberger committed Apr 7, 2024
1 parent 7f4e74a commit c46ec2e
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions src/MauiSettings/MauiSettingsGeneric.cs
Original file line number Diff line number Diff line change
Expand Up @@ -300,22 +300,22 @@ public static async Task<ConcurrentDictionary<string, Tuple<object, Type>>> ToCo
return setting;
}

public static Task<Tuple<string, Tuple<object, Type>>> ToSettingsTupleAsync<T>(Expression<Func<SO, T>> value)
=> ToSettingsTupleAsync(settings: SettingsObject, value: value);
public static Task<Tuple<string, Tuple<object, Type>>> ToSettingsTupleAsync<T>(Expression<Func<SO, T>> value, string? key = null)
=> ToSettingsTupleAsync(settings: SettingsObject, value: value, key: key);

public static async Task<Tuple<string, Tuple<object, Type>>> ToSettingsTupleAsync<T>(object? settings, Expression<Func<SO, T>> value)
public static async Task<Tuple<string, Tuple<object, Type>>> ToSettingsTupleAsync<T>(object? settings, Expression<Func<SO, T>> 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);
});

Expand Down Expand Up @@ -406,7 +406,10 @@ static async Task<bool> GetMetaFromDictionaryAsync(object settings, Dictionary<s
// Handles saving the settings to the Maui.Storage.Preferences
MauiSettingsResults result = await ProcessSettingsInfoAsync(
settingsObjectInfo, settingsInfo, mode, target, secureOnly: secureOnly, useValueFromSettingsInfo: useValueFromSettingsInfo, key: key, justTryLoading: justTryLoading);
if (result == MauiSettingsResults.EncryptionError || result == MauiSettingsResults.Failed) { return false; }
if (result == MauiSettingsResults.EncryptionError || result == MauiSettingsResults.Failed)
{
return false;
}
}
return true;
}
Expand Down Expand Up @@ -450,7 +453,7 @@ static async Task GetExpressionMetaAsync<T>(object settings, Expression<Func<SO,
OrignalSettingsObject = settings,
Info = memberExpression.Member,

}, new MauiSettingsInfo(), key: key);
}, new MauiSettingsInfo(), key: key, keeyEncrypted: true);
}
return new();
}
Expand Down

0 comments on commit c46ec2e

Please sign in to comment.