Visual Studio 2010:IDE 中类的 XML XSD 架构 [英] Visual Studio 2010 : XML XSD Schema to Classes within the IDE

查看:15
本文介绍了Visual Studio 2010:IDE 中类的 XML XSD 架构的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

每当我需要从 XML XSD 架构创建类文件时,我都会在 VS 中使用 .NET xsd.exe 工具和预构建事件,以确保我的类和架构在构建时彼此同步.这当然可以,但是...

Whenever I have needed to create a class file from an XML XSD schema, I use the .NET xsd.exe tool and prebuild events, in VS, to ensure that my classes and schemas are in sync with each other at build time. This of course works fine, however...

我注意到,如果 XSD 和派生类在同一个项目中,VS 会理解这种关系并在解决方案资源管理器中直观地将 CS 显示为 XSD 文件的子项.所以我想知道 Visual Studio 2010 中是否有任何功能可以在 IDE 中为我执行类创建,而不是依赖预构建脚本?

I have noticed that if the XSD and derived class are in the same project VS understands the relationship and visually displays the CS as a child of the XSD file in solution explorer. So I was wondering if there is any functionality in Visual Studio 2010 to perform class creation for me within the IDE rather than relying on the prebuild script?

例如,我会将 XSD 添加到项目中,在某处设置一些选项,然后 VS 接管并为我创建我的类.

For example, I would add the XSD to the project set some options somewhere and VS takes over and creates my classes for me.

VS 2010 是否支持这样的东西?还是我应该停止思考并继续使用 xsd.exe 和 prebuild.

Does VS 2010 support anything like this? Or should I just stop wondering and continue to use xsd.exe and prebuild.

编辑我还注意到,在 XSD 文件的属性下,我可以选择设置 Custom Tool,阅读描述这似乎接近我的目标,但我不确定正确的用法这个属性.

EDIT I have also noticed that under the properties of the XSD file I have the option to set a Custom Tool, reading the description this seems close to what I am aiming for but I am unsure of the correct usage for this property.

编辑此外,如果有解决方案,我需要它基于 VS2010 标配的特性/功能.我宁愿不使用第 3 方插件等

EDIT Also, if there is a solution I need this to be based on the features/functions that come as standard with VS2010. I would prefer to not use a 3rd party addon etc

推荐答案

Visual Studio 2010 本身不包含任何此类一般用途的功能.

Visual Studio 2010 in itself does not contain any such functionality for general consumption.

Visual Studio 在 ADO.NET 中的类型化数据集上下文中对这种 XSD 到代码的转换提供了一些有限的支持 - 但这些不是通用解决方案,它们正是针对一种使用场景.

Visual Studio has some limited support for this XSD-to-code conversion in the context of typed datasets in ADO.NET - but those are not general-purpose solutions, they are targeted at exactly that one usage scenario.

但是请查看 XSD2Code 插件,它正是这样做的

But do check out the XSD2Code add-in that does exactly that

这篇关于Visual Studio 2010:IDE 中类的 XML XSD 架构的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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