简体   繁体   English

WinRT应用程序中的app.config等效于什么?

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

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. 在Windows桌面开发(WinForms,WPF)中, app.config是放置诸如连接字符串或uri的东西之类的潜在位置。 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? WinRT应用程序中是否有类似的概念?

The closest thing I see is there is the local application data: http://msdn.microsoft.com/en-us/library/windows/apps/hh700361.aspx 我看到的最接近的东西是本地应用程序数据: http : //msdn.microsoft.com/zh-cn/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? 有没有办法在代码外部设置Windows.Storage.ApplicationData.Current.LocalSettings.Values的值? (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 ? 通过尝试将它们与app.config进行比较,我是否错过了Windows.Storage.ApplicationData.Current.LocalSettings.Values的要点? Or am I correct in my comparison but missing the way to access them outside of the app? 还是我的比较正确但缺少在应用程序外部访问它们的方式?

Please set me straight. 请让我挺直。

Thanks. 谢谢。

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). 正如Victory指出的那样,我不确定这是否与现有的SO问题重复(因为我也不认为这完全可以回答)。

app.config in .NET provided a way to have some "init" type values and those were easily accessible via System.Configuration APIs. .NET中的app.config提供了一种具有一些“初始”类型值的方法,这些值可以通过System.Configuration API轻松访问。 System.Configuration is not a part of the NETFX Core profile so this automatic wire-up is not possible. System.Configuration并非NETFX Core配置文件的一部分,因此无法进行自动连接。 Consider that app.config was just XML and the APIs presented a deserialized view of that you could accomplish the same thing. 考虑一下app.config只是XML,API提供了反序列化的视图,您可以完成相同的事情。

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. 我会将配置文件设置为所需的格式(xml,json),然后在应用启动时根据需要将其反序列化为强类型类, 或者仅使用XML / JSON API加载并查询您所需要的特定节点想。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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