From 5fbdbd98c6302abdfc306c06b0ab1cba9db1589b Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Tue, 19 Mar 2024 17:36:19 +0000 Subject: [PATCH] [create-pull-request] automated change --- src/MauiSettings.Example/App.xaml.cs | 2 +- src/MauiSettings/Helper/MauiSettingsHelper.cs | 8 +- .../Helper/MauiSettingsObjectHelper.cs | 2 +- src/MauiSettings/MauiSettingsGeneric.cs | 104 +++++++++--------- 4 files changed, 58 insertions(+), 58 deletions(-) diff --git a/src/MauiSettings.Example/App.xaml.cs b/src/MauiSettings.Example/App.xaml.cs index 4890537..0592899 100644 --- a/src/MauiSettings.Example/App.xaml.cs +++ b/src/MauiSettings.Example/App.xaml.cs @@ -23,7 +23,7 @@ public App() { await SettingsApp.LoadSettingsAsync(Hash); });*/ - MainPage = new AppShell(); + MainPage = new AppShell(); } protected override void OnSleep() diff --git a/src/MauiSettings/Helper/MauiSettingsHelper.cs b/src/MauiSettings/Helper/MauiSettingsHelper.cs index d7f2126..44fcde6 100644 --- a/src/MauiSettings/Helper/MauiSettingsHelper.cs +++ b/src/MauiSettings/Helper/MauiSettingsHelper.cs @@ -74,7 +74,7 @@ public static T GetSettingsValue(string key, T defaultValue) } public static T ChangeSettingsType(object settingsValue, T defaultValue) => (T)Convert.ChangeType(settingsValue, typeof(T)); - + // Docs: https://docs.microsoft.com/en-us/dotnet/maui/platform-integration/storage/secure-storage?tabs=ios // Only string is allowed for secure storage public static async Task GetSecureSettingsValueAsync(string key, string defaultValue) @@ -126,9 +126,9 @@ public static async Task SetSecureSettingsValueAsync(string key, string value) } public static void ClearSettings() => Preferences.Clear(); - + public static void ClearSecureSettings() => SecureStorage.Default.RemoveAll(); - - #endregion + + #endregion } } diff --git a/src/MauiSettings/Helper/MauiSettingsObjectHelper.cs b/src/MauiSettings/Helper/MauiSettingsObjectHelper.cs index 3d47970..d004e60 100644 --- a/src/MauiSettings/Helper/MauiSettingsObjectHelper.cs +++ b/src/MauiSettings/Helper/MauiSettingsObjectHelper.cs @@ -64,7 +64,7 @@ public static void SetSettingValue(MemberInfo memberInfo, object settings, objec { //throw new NotSupportedException($"MauiSettings: The type '{memberInfo.GetType()}' is not supported for the field: {memberInfo.Name}", exc); } - + } public static Type GetSettingType(MemberInfo memberInfo) diff --git a/src/MauiSettings/MauiSettingsGeneric.cs b/src/MauiSettings/MauiSettingsGeneric.cs index 3a1fb3d..d844f73 100644 --- a/src/MauiSettings/MauiSettingsGeneric.cs +++ b/src/MauiSettings/MauiSettingsGeneric.cs @@ -70,7 +70,7 @@ public MauiSettingsGeneric(SO settingsObject, string key) public static void LoadSettings() => LoadSettings(settings: SettingsObject); public static void LoadSetting(Expression> value) => LoadObjectSetting(SettingsObject, value); - + public static async Task LoadSettingAsync(Expression> value, string? key = null) { await Task.Run(async delegate @@ -80,138 +80,138 @@ await Task.Run(async delegate } public void LoadObjectSettings() => LoadSettings(this); - - public static void LoadObjectSetting(object settingsObject, Expression> value) + + public static void LoadObjectSetting(object settingsObject, Expression> value) => GetExpressionMeta(settings: settingsObject, value, MauiSettingsActions.Load); - + public static Task LoadObjectSettingAsync(object settingsObject, Expression> value, string? key = null) => Task.Run(async delegate { await GetExpressionMetaAsync(settings: settingsObject, value, MauiSettingsActions.Load, key: key); }); - + public static void LoadSettings(object settings) => GetClassMeta(settings: settings, mode: MauiSettingsActions.Load, key: null); - + public static Task LoadSettingsAsync(string? key = null) => Task.Run(async delegate { await LoadSettingsAsync(settings: SettingsObject, key: key); }); - + public static Task LoadSettingsAsync(object settings, string? key = null) => Task.Run(async delegate { await GetClassMetaAsync(settings: settings, mode: MauiSettingsActions.Load, key: key); }); - + public static Task LoadSecureSettingsAsync(string? key = null) => Task.Run(async delegate { await LoadSecureSettingsAsync(settings: SettingsObject, key: key); }); - + public static Task LoadSecureSettingsAsync(object settings, string? key = null) => Task.Run(async delegate { await GetClassMetaAsync(settings: settings, mode: MauiSettingsActions.Load, secureOnly: true, key: key); }); - + public static Task LoadSettingsAsync(Dictionary> dictionary, bool save = true, string? key = null) => Task.Run(async delegate { await LoadSettingsAsync(settings: SettingsObject, dictionary: dictionary, save: save, key: key); }); - + public static Task LoadSettingsAsync(string key, Tuple data, bool save = true, string? skey = null) => Task.Run(async delegate { - await LoadSettingsAsync(settings: SettingsObject, dictionary: new() { { key, data} }, save: save, key: skey); + await LoadSettingsAsync(settings: SettingsObject, dictionary: new() { { key, data } }, save: save, key: skey); }); - - public static Task LoadSettingsAsync(object settings, Dictionary> dictionary, bool save = true, string? key = null) + + public static Task LoadSettingsAsync(object settings, Dictionary> dictionary, bool save = true, string? key = null) => Task.Run(async delegate { await GetMetaFromDictionaryAsync(settings: settings, dictionary: dictionary, mode: MauiSettingsActions.Load, secureOnly: false, key: key); // Save the restored settings right away if (save) await SaveSettingsAsync(settings: settings, key: key); }); - + #endregion #region SaveSettings public static void SaveSettings() => SaveSettings(SettingsObject); - + public static void SaveSetting(Expression> value) => SaveObjectSetting(SettingsObject, value); - - public static void SaveObjectSetting(object settings, Expression> value) + + public static void SaveObjectSetting(object settings, Expression> value) => GetExpressionMeta(settings, value, MauiSettingsActions.Save); - + public void SaveObjectSetting(Expression> value) => SaveObjectSetting(this, value); - + public void SaveObjectSettings() => SaveSettings(this); - + public static void SaveSettings(object settings) => GetClassMeta(settings, MauiSettingsActions.Save); - + public static Task SaveSettingsAsync(string? key = null) => Task.Run(async delegate { await SaveSettingsAsync(settings: SettingsObject, key: key); }); - + public static Task SaveSettingsAsync(object settings, string? key = null) => Task.Run(async delegate { await GetClassMetaAsync(settings: settings, mode: MauiSettingsActions.Save, key: key); }); - + public static Task SaveSecureSettingsAsync(string? key = null) => Task.Run(async delegate { await SaveSecureSettingsAsync(settings: SettingsObject, key: key); }); - + public static Task SaveSecureSettingsAsync(object settings, string? key = null) => Task.Run(async delegate { await GetClassMetaAsync(settings: settings, mode: MauiSettingsActions.Save, secureOnly: true, key: key); }); - + #endregion #region DeleteSettings public static void DeleteSettings() => DeleteSettings(SettingsObject); - + public static void DeleteSetting(Expression> value) => DeleteObjectSetting(SettingsObject, value); - + public void DeleteObjectSetting(Expression> value) => DeleteObjectSetting(this, value); - + public static void DeleteObjectSetting(object settings, Expression> value) => GetExpressionMeta(settings, value, MauiSettingsActions.Delete); - + public void DeleteObjectSettings() => DeleteSettings(this); - + public static void DeleteSettings(object settings) => GetClassMeta(settings, MauiSettingsActions.Delete); - + #endregion #region LoadDefaults public static void LoadDefaultSettings() => LoadDefaultSettings(SettingsObject); - + public static void LoadDefaultSetting(Expression> value) => LoadObjectDefaultSetting(SettingsObject, value); - + public void LoadObjectDefaultSetting(Expression> value) => LoadObjectDefaultSetting(this, value); - - public static void LoadObjectDefaultSetting(object settings, Expression> value) + + public static void LoadObjectDefaultSetting(object settings, Expression> value) => GetExpressionMeta(settings, value, MauiSettingsActions.LoadDefaults); - + public void LoadObjectDefaultSettings() => LoadDefaultSettings(this); - + public static void LoadDefaultSettings(object settings) => GetClassMeta(settings, MauiSettingsActions.LoadDefaults); - + #endregion #region Conversion - public static Task>> ToDictionaryAsync() + public static Task>> ToDictionaryAsync() => ToDictionaryAsync(settings: SettingsObject); - + public static async Task>> ToDictionaryAsync(object settings) { if (true) @@ -245,13 +245,13 @@ public static async Task>> ToDictionaryAs } }); */ - return setting; + return setting; } } public static Task>> ToConcurrentDictionaryAsync() => ToConcurrentDictionaryAsync(settings: SettingsObject); - + public static async Task>> ToConcurrentDictionaryAsync(object settings) { ConcurrentDictionary> setting = new(); @@ -287,7 +287,7 @@ public static async Task>> ToCo } public static Task>> ToSettingsTupleAsync(Expression> value) => ToSettingsTupleAsync(settings: SettingsObject, value: value); - + public static async Task>> ToSettingsTupleAsync(object settings, Expression> value) { MauiSettingsInfo? info = await GetExpressionMetaAsKeyValuePairAsync(settings: settings, value: value); @@ -373,7 +373,7 @@ static async Task GetMetaFromDictionaryAsync(object settings, Dictionary>? keyPair = dictionary?.FirstOrDefault(keypair => + KeyValuePair>? keyPair = dictionary?.FirstOrDefault(keypair => keypair.Key.EndsWith(mInfo.Name //?.Replace("get_", string.Empty) )); @@ -426,7 +426,7 @@ static async Task GetExpressionMetaAsync(object settings, Expression GetExpressionMetaAsKeyValuePairAsync(object settings, Expression> value, string? key = null) @@ -631,7 +631,7 @@ List settingBaseAttributes if (!secure) { // If only secure storage should be loaded, stop here. - if (secureOnly) + if (secureOnly) return true; // If the value is not used from the passed settingsInfo, load it @@ -649,7 +649,7 @@ List settingBaseAttributes else settingsInfo.Value = MauiSettingsHelper.ChangeSettingsType(settingsInfo.Value, settingsInfo.Default); break; - } + } } else if (settingsInfo.SettingsType == typeof(string)) { @@ -706,7 +706,7 @@ List settingBaseAttributes } // Sets the loaded value back to the settingsObject MauiSettingsObjectHelper.SetSettingValue(settingsObjectInfo.Info, settingsObjectInfo.OrignalSettingsObject, settingsInfo.Value, settingsInfo.SettingsType); - + break; case MauiSettingsActions.Save: // Get the value from the settingsObject @@ -730,7 +730,7 @@ List settingBaseAttributes string encryptedString = EncryptionManager.EncryptStringToBase64String(secureString, key); await MauiSettingsHelper.SetSecureSettingsValueAsync(settingsInfo.Name, encryptedString); } - else + else await MauiSettingsHelper.SetSecureSettingsValueAsync(settingsInfo.Name, secureString); } else @@ -781,7 +781,7 @@ List settingBaseAttributes string encryptedString = EncryptionManager.EncryptStringToBase64String(secureString, key); await MauiSettingsHelper.SetSecureSettingsValueAsync(settingsInfo.Name, encryptedString); } - else + else await MauiSettingsHelper.SetSecureSettingsValueAsync(settingsInfo.Name, secureString); } else @@ -823,7 +823,7 @@ List settingBaseAttributes string encryptedString = EncryptionManager.EncryptStringToBase64String(secureString, key); await MauiSettingsHelper.SetSecureSettingsValueAsync(settingsInfo.Name, encryptedString); } - else + else await MauiSettingsHelper.SetSecureSettingsValueAsync(settingsInfo.Name, secureString); } else