【问题标题】:Can someone explain, in plain English, the difference between ConfigurationSection and ConfigurationElement?有人可以用简单的英语解释 ConfigurationSection 和 ConfigurationElement 之间的区别吗?
【发布时间】:2011-04-18 12:48:49
【问题描述】:

我正在阅读一篇关于 .NET 配置命名空间(找到 here)的精彩文章,其中讨论了创建自定义部分、元素、集合、小部件和飞行烤面包机。我唯一的抱怨是这篇文章只是技术性的,没有提供任何概念背景。 MSDN 似乎也没有太多概念性信息。

那么有人可以解释一下什么是“部分”,什么是“元素”,以及何时适合使用它们?

【问题讨论】:

  • 嗯,我知道这已经有一段时间了,你可能已经找到了答案,如果你有请分享一下吗?

标签: c# .net configuration app-config


【解决方案1】:

我认为本系列文章更适合您阅读,它精彩地向您介绍了 C# 中的所有配置细节:

Unraveling the Mysteries of .NET 2.0 Configuration

Decoding the Mysteries of .NET 2.0 Configuration

Cracking the Mysteries of .NET 2.0 Configuration

用简单的话回答您的问题,ConfigurationSection 是一个包含多个ConfigurationElement 和/或ConfigurationElementCollection 的容器。 ConfigurationSection 的父级始终是 <configuration>,它是配置文件中的根元素。

ConfigurationElement 是一个容器和/或单个元素,并且始终是 ConfigurationSection 的一部分。

【讨论】:

  • :) 我提供的链接是您引用的三篇文章中的第一篇。
  • 糟糕...“Enter”键发送。我的意思是补充说“ConfigurationSection”仍然让我感到困惑。有一个 ConfigurationSectionGroup 类和 ConfigurationSectionCollection 类。此外,由于 ConfigurationElement 可以是多个元素的容器,我仍然不明白为什么会有不同的 ConfigurationSection 类。它们似乎基本相同。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-10-10
  • 2019-05-14
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多