为configsections提供Intellisense/XSD验证

5
在一个小的C#项目中,我正在尝试创建一个简单的自定义configsection。我遵循了CodeProject: Unraveling the Mysteries of .NET 2.0 Configuration中的说明,一切都很好……除了我没有得到配置的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>

在这篇文章中(XSDExtractor),我发现了一个可以为configsection创建xsd文件的工具。它可以为主要属性(例如“price”)和单个元素(“cook”)提供智能感知和验证,运行良好。但是,我无法使其适用于集合(即“toppings”)。
我的问题:
1. 是否有其他工具可以生成ConfigurationSection类的xsd? 2. 有人能够成功地在具有集合属性的ConfigurationSection上运行XSDExtractor吗?
非常感谢, Nicola
1个回答

5

我没有使用过XSDExtractor,但我强烈推荐一个工具——Configuration Section Designer。它是Visual Studio的插件,允许你以图形化的方式设计.NET配置节,并自动生成所需的所有代码和模式定义(XSD)。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接