自定义配置部分和app.config

发布于 2024-11-19 19:05:20 字数 373 浏览 5 评论 0原文

我有一些传入的 XML 文档,我需要检查此传入 XML 中可配置的属性,如果正在检查的 XML 文档中不存在该属性,则添加它。

要检查的属性将在app.config文件中指定 OrderRequest.orderDetails.orderSummary.testCount,我需要检查元素OrderRequest下是否存在testCount属性。如果否,请将其与其值一起添加,该值也在 app.config

INCOMING XML 中指定 ->从 app.config 中读取需要在此 XML 文件中检查的属性 -->使用 XDocument 读取传入的 XML -->如果传入 XML 中不存在该属性,请将其添加到 XML 中。

有什么想法我可以继续做下去吗?

I have some incoming XML documents, I need to check attributes that are configurable in this coming XML and if the attribute is not there in the XML document being checked add it.

The attributes to be checked will be specified in the app.config file
OrderRequest.orderDetails.orderSummary.testCount, I need to check if the testCount attribute exists under the element OrderRequest. If No add it along with it’s value which is also specified in the app.config

INCOMING XML --> Read the attributes from the app.config which need to be checked in this XML file --> Read the incoming XML using XDocument --> If the attribute is not there in the incomg XML add it to the XML.

Any ideas how I can go on this.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

吃素的狼 2024-11-26 19:05:20

我写了一系列关于如何创建自定义配置部分的文章,可以在这里找到:http:// /dotnetslackers.com/articles/CustomConfiguration/default.aspx

这是静态开发任务吗?我的意思是,您是否只测试 testCount 属性,或者这是通用的循环遍历元素类型并检查其所有属性以确保它们存在的方法?

无论哪种方式,本质上您都必须找到一个元素,获取其名称,访问自定义配置部分并查找名称,使用 GetAttribute 方法检查属性是否存在,如果不存在,则将新属性附加到元素。

HTH。

I wrote a series of articles on how to create custom configuration sections, which can be found here: http://dotnetslackers.com/articles/CustomConfiguration/default.aspx

Is this a static development task? What I mean is, are you only testing the testCount attribute, or is this generic to say loop through the element type and check all of its attributes to ensure they are there?

Either way, essentially you have to find an element, get its name, access your custom configuration section and lookup the name, use the GetAttribute method to check for attribute existence, and append a new attribute to the element if not.

HTH.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文