在 app.config 中存储树状信息的最佳方式

发布于 2024-07-15 10:10:43 字数 357 浏览 4 评论 0原文

在 app.config 中存储像下面这样的树的最佳方法是什么?我将如何从中反序列化此信息?

Tree
|-node1-
|       |-name - value
|       |-name - value
|       | ......
|-node2-
|       |-name - value
|       |-name - value
|       | ......
|-node3-
|       |-name - value
|       |-name - value
|       | ......

如果有帮助的话,我可以将该树转换为 xml。

感谢您提前提供的任何帮助。

What would be the best way to store a tree like the one below in app.config and how would I deserialize this information from it?

Tree
|-node1-
|       |-name - value
|       |-name - value
|       | ......
|-node2-
|       |-name - value
|       |-name - value
|       | ......
|-node3-
|       |-name - value
|       |-name - value
|       | ......

I can convert that tree to xml if that helps.

Thanks for any assistance in advance.

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

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

发布评论

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

评论(3

梦初启 2024-07-22 10:10:43

使用自定义配置部分。 有关执行此操作的一种方法,请参阅配置节设计器。 您可以手动执行此操作,但您可能想使用 CSD 并查看它生成的代码。

Use a custom configuration section. For one way to do this, see Configuration Section Designer. You can do it manually, but you might like to play with CSD and see the code it generates.

苹果你个爱泡泡 2024-07-22 10:10:43

您可以使用自己的类型扩展 .config。 这些可以是包含其他元素和属性的元素。 这个领域的记录似乎很少,但有一些例子。

从 System.Configuration.ConfigurationElement 类开始。

You can extend .config with your own types. These can be elements containing other elements and attributes. This area does seem to be poorly documented but there are examples out there.

Start with the System.Configuration.ConfigurationElement class.

再可℃爱ぅ一点好了 2024-07-22 10:10:43

您可以在应用程序中使用带有 .config 扩展名的基于 xml 的文档(如 NLog.config 等),并使用自定义数据提供程序来读取 xml 数据并将其转换为树状数据。

<Nodes>
    <Node Name="Node1" Value="Value1">
       <Node Name="Node1.1" Value="Value1.2">
       </Node>

       <Node Name="Node1.2" Value="Value1.2">
       </Node>
    </Node>

    <Node Name="Node2" Value="Value2">
    </Node>
</Nodes>

或者您可以使用自定义配置部分

You can use and xml based document inside your app with .config extension( like NLog.config , ... ) and use a custom data provider to read the xml data and convert they to tree-like ds.

<Nodes>
    <Node Name="Node1" Value="Value1">
       <Node Name="Node1.1" Value="Value1.2">
       </Node>

       <Node Name="Node1.2" Value="Value1.2">
       </Node>
    </Node>

    <Node Name="Node2" Value="Value2">
    </Node>
</Nodes>

or you can use a custom config section

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