在一个小型 C# 项目中,我正在尝试创建一个简单的自定义配置部分。 我按照 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) 中,我找到了一个为配置部分创建 xsd 文件的工具。它工作正常,即它为主要属性(例如“价格”)和单个元素(“cook”)提供智能感知和验证。但是我无法让它适用于系列(“浇头”)。
我的问题:
- 是否有任何其他工具可以提供 ConfigurationSection 类的 xsd 生成?
- 有人在具有集合属性的 ConfigurationSection 上成功运行 XSDExtractor 了吗?
非常感谢, 尼古拉
最佳答案
我没有使用过 XSDExtractor,但我强烈推荐的一个工具是 Configuration Section Designer .它是一个 Visual Studio 插件,允许您以图形方式设计 .NET 配置部分并自动为它们生成所有必需的代码和架构定义 (XSD)。
关于c# - 为配置部分提供智能感知/xsd 验证,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/334473/