diff --git a/src/MauiSettings/MauiSettingsGeneric.cs b/src/MauiSettings/MauiSettingsGeneric.cs index d844f73..fbdf92b 100644 --- a/src/MauiSettings/MauiSettingsGeneric.cs +++ b/src/MauiSettings/MauiSettingsGeneric.cs @@ -71,13 +71,18 @@ public MauiSettingsGeneric(SO settingsObject, string key) public static void LoadSetting<T>(Expression<Func<SO, T>> value) => LoadObjectSetting(SettingsObject, value); - public static async Task LoadSettingAsync<T>(Expression<Func<SO, T>> value, string? key = null) - { - await Task.Run(async delegate + public static Task LoadSettingAsync<T>(Expression<Func<SO, T>> value, string? key = null) + => Task.Run(async delegate { await LoadObjectSettingAsync(SettingsObject, value, key: key); }); - } + + public static Task LoadSecureSettingAsync<T>(Expression<Func<SO, T>> value, string? key = null) + => Task.Run(async delegate + { + await LoadSecureObjectSettingAsync(SettingsObject, value, key: key); + }); + public void LoadObjectSettings() => LoadSettings(this); @@ -89,6 +94,11 @@ public static Task LoadObjectSettingAsync<T>(object settingsObject, Expression<F { await GetExpressionMetaAsync(settings: settingsObject, value, MauiSettingsActions.Load, key: key); }); + public static Task LoadSecureObjectSettingAsync<T>(object settingsObject, Expression<Func<SO, T>> value, string? key = null) + => Task.Run(async delegate + { + await GetExpressionMetaAsync(settings: settingsObject, value, MauiSettingsActions.Load, secureOnly: true, key: key); + }); public static void LoadSettings(object settings) => GetClassMeta(settings: settings, mode: MauiSettingsActions.Load, key: null); @@ -307,7 +317,7 @@ public static Task ExhangeKeyAsync(string? newKey = null, string? oldKey = null) #endregion #region Private - static List<MemberInfo> GetClassMetaAsList(object settings) + static List<MemberInfo>? GetClassMetaAsList(object settings) { lock (lockObject) { @@ -415,7 +425,7 @@ static void GetExpressionMeta<T>(object settings, Expression<Func<SO, T>> value, } } - static async Task GetExpressionMetaAsync<T>(object settings, Expression<Func<SO, T>> value, MauiSettingsActions mode, MauiSettingsTarget target = MauiSettingsTarget.Local, string? key = null) + static async Task GetExpressionMetaAsync<T>(object settings, Expression<Func<SO, T>> value, MauiSettingsActions mode, MauiSettingsTarget target = MauiSettingsTarget.Local, bool secureOnly = false, string? key = null) { if (value.Body is MemberExpression memberExpression) @@ -425,7 +435,7 @@ static async Task GetExpressionMetaAsync<T>(object settings, Expression<Func<SO, OrignalSettingsObject = settings, Info = memberExpression.Member, - }, new MauiSettingsInfo(), mode, target, key: key); + }, new MauiSettingsInfo(), mode, target, secureOnly: secureOnly, key: key); } }