简体   繁体   中英

Is There a Settings Viewer/Manager for Windows 8 apps?

For testing my roaming and/or local settings, I'd like to be able to clear all the settings.

I could do it like so, I guess:

App.roamingSettings.Value["SomeVal"] = string.Empty;
App.roamingSettings.Value["SomeOtherVal"] = string.Empty;
App.roamingSettings.Value["YetAnotherVal"] = string.Empty;
...
etc.

...but I'd rather have some quicker, cleaner (no pun intended) way. Is there one?

Also, relatedly, it would be nice to have a "Settings Manager" utility for quickly verifying they are what you think they are, too. Does anybody know of one?

UPDATE

This is my attempt to "roll my own" based on the answer; so far, no go:

string roamingSettingPairs = string.Empty;
for (int i = 0; i < App.roamingSettings.Values.Count; i++)
{
    // Print out whatever you want to verify that everything is as it should be
    //string roamingSettingName = App.roamingSettings.Name[i].ToString();
    //string roamingSettingValue = App.roamingSettings.Values[i].ToString();
    Dictionary<string, object> roamingSettingVals = App.roamingSettings.Values;
    string roamingSettingName = roamingSettingVals.Keys[i];
    object roamingSettingObj = roamingSettingVals.Values[i];
    //roamingSettingPairs = string.Format("{0}{1}={2}{3}", roamingSettingPairs, roamingSettingName,
      //                                  roamingSettingValue, Environment.NewLine);
}

You can delete all of your roaming settings using this code:

ApplicationData.Current.RoamingSettings.Values.Clear();

For a Settings Manager, I would probably just use a for loop like so:

for (int i = 0; i < ApplicationData.Current.RoamingSettings.Values.Count; i++)
{
    // Print out whatever you want to verify that everything is as it should be
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM