对配置提供intellisense / xsd验证 [英] Providing intellisense/xsd validation to configsections

查看:198
本文介绍了对配置提供intellisense / xsd验证的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在一个小的c#项目中,我试图创建一个简单的自定义配置文件。
我按照代码项目:解开.NET 2.0配置的奥秘的说明并且一切工作很好...除了我不在配置上获得xsd验证和intellisense的事实。

in a small c# project, I'm trying to create a simple custom configsection. I followed the instructions in CodeProject: Unraveling the Mysteries of .NET 2.0 Configuration and everything work nicely... apart from the fact that I don't get xsd validation and intellisense on the config.

我的配置如下所示。 / p>

My config is shown below.

<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文件。它工作正常,即它提供主要属性(例如价格)和单个元素(厨师)的智能感知和验证。

On this article (XSDExtractor) I found a tool that creates an xsd file for the configsection. It works fine, i.e. it provides intellisense and validation, for the main attributes (e.g. "price") and the single elements ("cook"). However I could not make it work for the collections (the "toppings").

我的问题:


  1. 是否有任何其他工具提供xs​​d生成ConfigurationSection类?

  2. 有人在具有集合属性的ConfigurationSection上成功运行XSDExtractor?

感谢很多,
Nicola

Thanks a lot, Nicola

推荐答案

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

I haven't used XSDExtractor but one tool which I strongly recommend is Configuration Section Designer. It's a Visual Studio add-in that allows you to graphically design .NET Configuration Sections and automatically generates all the required code and a schema definition (XSD) for them.

这篇关于对配置提供intellisense / xsd验证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆