Providing intellisense/xsd validation to configsections

风格不统一 提交于 2019-12-06 03:57:38

问题


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.

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>

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").

My questions:

  1. Is there any other tool that provides xsd generation of ConfigurationSection classes?
  2. Has someone run XSDExtractor successfully on a ConfigurationSection with a collection property?

Thanks a lot, Nicola


回答1:


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.



来源:https://stackoverflow.com/questions/334473/providing-intellisense-xsd-validation-to-configsections

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!