什么是WinRT应用程序中的app.config等效项? [英] What is the equivalent of an app.config in a WinRT app?

查看:91
本文介绍了什么是WinRT应用程序中的app.config等效项?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Windows桌面开发(WinForms,WPF)中,app.config是在应用程序中放置诸如连接字符串或uri之类的东西的潜在位置.这样,最终用户就可以在整个应用程序范围内更改这些设置,而不必重新开发和重新部署开发人员.

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.

WinRT应用程序中是否有类似的概念?

Is there a similar concept in WinRT apps?

我看到的最接近的是本地应用程序数据: http://msdn.microsoft.com/en-us/library/windows/apps/hh700361.aspx

The closest thing I see is there is the local application data: http://msdn.microsoft.com/en-us/library/windows/apps/hh700361.aspx

我遇到的麻烦是好像在本地应用程序数据中创建值和设置值都在代码内完成.有没有办法在代码外部设置Windows.Storage.ApplicationData.Current.LocalSettings.Values中的值? (类似于您如何在文本编辑器中更改配置值)?我希望单击设置超级按钮可以打开一种访问这些设置的方式,但是我什么都没看到.

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.

通过尝试将它们与app.config进行比较,我是否错过了Windows.Storage.ApplicationData.Current.LocalSettings.Values的要点?还是我的比较是正确的,但是缺少在应用程序外部访问它们的方法?

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?

请让我挺直.

谢谢.

推荐答案

正如Victory指出的那样,我不确定这是否与现有的SO问题重复(因为我也不认为这也得到了完全回答).

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提供了一种具有一些初始"类型值的方法,这些值可以通过System.Configuration API轻松访问. System.Configuration并非NETFX Core配置文件的一部分,因此无法进行自动连接.考虑一下app.config只是XML,而API则提供了反序列化视图,您可以完成相同的事情.

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.

我将以您想要的格式(xml,json)放置您的配置,然后在您的应用启动时,如果您想使用仅使用XML/JSON 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.

这篇关于什么是WinRT应用程序中的app.config等效项?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆