问题
In windows desktop development (WinForms, WPF), the app.config
is a potential place to put things like connection strings or uri's used within the app. This allows the end user to change these settings, application wide, without having to have a developer rebuild and redeploy.
Is there a similar concept in WinRT apps?
The closest thing I see is there is the local application data: http://msdn.microsoft.com/en-us/library/windows/apps/hh700361.aspx
The trouble I am having is that it seems like creating values and setting values in local application data are all done within code. Is there a way to set the values in Windows.Storage.ApplicationData.Current.LocalSettings.Values
outside of the code? (similar to how you can change config values in a text editor)? I was hoping that clicking the settings charm would open up a way to access these settings, but I didn't see anything.
Am I missing the point of Windows.Storage.ApplicationData.Current.LocalSettings.Values
by trying to compare them to an app.config
? Or am I correct in my comparison but missing the way to access them outside of the app?
Please set me straight.
Thanks.
回答1:
I'm not sure this is a duplicate of an existing SO question as Victory points out (as I don't think that was totally answered as well).
app.config in .NET provided a way to have some "init" type values and those were easily accessible via System.Configuration APIs. System.Configuration is not a part of the NETFX Core profile so this automatic wire-up is not possible. Consider that app.config was just XML and the APIs presented a deserialized view of that you could accomplish the same thing.
I would put your config in the format you want (xml, json) then when your app starts you can deserialize that into a strongly typed class if you wanted or just use the XML/JSON APIs to load up and query the particular node that you want.
来源:https://stackoverflow.com/questions/19994632/what-is-the-equivalent-of-an-app-config-in-a-winrt-app