What is the equivalent of an app.config in a WinRT app?

北战南征 提交于 2019-12-22 18:34:12

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!