c# - 为配置部分提供智能感知/xsd 验证

标签 c# configuration configsection

在一个小型 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”)提供智能感知和验证。但是我无法让它适用于系列(“浇头”)。

我的问题:

  1. 是否有任何其他工具可以提供 ConfigurationSection 类的 xsd 生成?
  2. 有人在具有集合属性的 ConfigurationSection 上成功运行 XSDExtractor 了吗?

非常感谢, 尼古拉

最佳答案

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

关于c# - 为配置部分提供智能感知/xsd 验证,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/334473/

相关文章:

asp.net - 找不到元素 'elmah'的架构信息

c# - 从相对路径获取绝对URL(重构方法)

c# - 以编程方式查找对象使用的内存

asp.net - web.config 和 app.config 中不同 Entity Framework 连接字符串的问题

c++ - C++ 中的多类型容器

configuration - 如何修复 "Your account does not belong to the same domain as this cloud project or app"错误?

c# - 是否可以在依赖 dll 的应用程序配置中定义 <configSections>

.net - 自定义 app.config 配置部分处理程序

c# - dotnet 核心 File.Move 问题

c# - 在 C# 中以编程方式设置浏览器代理设置