C# 将 xsd 转换为 ConfigurationSection

C# converting xsd to ConfigurationSection

我正在使用 Visual-Studio-2012

我正在使用 ConfigurationSection class 在 app.config 中声明新的自定义配置部分。

我需要以最有效的方式使用它,所以:

  1. 使用Intellisense 功能,所以当我在app.config 中编写代码时,会自动检测sections 和element collections 标签。 我已经检查过了,发现 XSD 可能是一个解决方案。
  2. 我想从 xsd 文件自动生成一个 class(使用相关代码,使用 ConfigurationSection、ConfigurationProperty 等) - 否则,我需要创建一个模板文件(使用相关标签)来自 ConfigurationSection class.

我怎样才能做到以上几点? 如果我不能 - 最好的创作方式是什么?

谢谢:)

  1. 是的。应使用XSD。

    打开 XSD 文件并在属性中选择架构即可使用 Intellisense 功能。

  2. 我发现添加ConfigurationSection的class是一个很好的态度