문제

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
}
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top