Refactor Application Settings and Support for Packaged/Unpackaged Mode #1924 #2014
+434
−362
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR replaces the legacy ApplicationData-based settings system with a new SettingsHelper class. It adds support for both packaged and unpackaged app scenarios.
Closes #1924.
Old Settings System:
appData.LocalSettings.Values[SettingsKeys.IsLeftMode] = true;
New Settings System:
SettingsHelper.Current.IsLeftMode = true;
Note
Settings are automatically saved when changed.
Important Note on List Types:
Direct modification of list items won't persist changes:
SettingsHelper.Current.myList.Add(item); // ❌ This won't work
SettingsHelper Architecture:
Uses an ISettingsProvider abstraction.
In packaged mode: uses ApplicationDataContainer.
In unpackaged mode: uses JsonSettingsProvider.
Adding a New Setting:
Supported Types:
In unpackaged mode (JSON), you can serialize most types easily.
In packaged mode, ApplicationDataContainer supports only limited types directly:
Other types (e.g., decimal, List) are serialized to JSON before being stored.
Vector Types:
Types like Vector2, Vector3, and Vector4 do not work in regular mode. Instead, use wrapper classes like Vector2Data, Vector3Data, and Vector4Data: