为配置提供intellisense/xsd验证

5 c# configuration configsection

在一个小型的c#项目中,我正在尝试创建一个简单的自定义配置部分.我按照CodeProject中的说明进行操作:解开.NET 2.0配置之谜,一切都运行得很好......除了我没有在配置上获得xsd验证和智能感知这一事实.

我的配置如下所示.

<configuration>
 <configSections>
    <section name="pizza" type="TestConfig.Configuration.PizzaConfigurationSection, TestConfig.Configuration"/>
 </configSections>

 <pizza name="Margherita" timeToCook="00:10:00" price="15.12">
   <cook firstName="Nicola" lastName="Carrer" rank="7" />
   <toppings>
     <add name="Mozzarella" percentage="0.6" />
     <add name="Tomato sauce" percentage="0.28" />
     <add name="Oregano" percentage="0.02" />
     <add name="Mushrooms" percentage="0.1" />
   </toppings>
 </pizza>
</configuration>
Run Code Online (Sandbox Code Playgroud)

在本文(XSDExtractor)上,我找到了一个为configsection创建xsd文件的工具.它工作正常,即它为主要属性(例如"价格")和单个元素("烹饪")提供智能感知和验证.但是我无法使其适用于收藏品("浇头").

我的问题:

  1. 是否有其他工具提供xs​​d生成的ConfigurationSection类?
  2. 有人在具有集合属性的ConfigurationSection上成功运行XSDExtractor吗?

非常感谢,尼古拉

daw*_*der 5

我没有使用XSDExtractor,但我强烈推荐的一个工具是Configuration Section Designer.它是一个Visual Studio加载项,允许您以图形方式设计.NET配置节,并自动为它们生成所有必需的代码和模式定义(XSD).