在 WinRT 项目中使用 XSD 文件 [英] Using XSD files in WinRT Projects

查看:36
本文介绍了在 WinRT 项目中使用 XSD 文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在 WinRT(Windows 应用商店/Metro)项目中使用一些现有的 C# 代码.

此代码依赖于一些使用 XSD 生成的 xml 文件.

不幸的是,旧的 XmlDocument 类似乎在 WinRT 中不可用......有一些替代方案,但它们似乎不太一样 - 所以我需要为 WinRT 生成一些新文件.

有没有办法将 XSD 文件导入 WinRT 项目,以便生成所有数据类和枚举并可以在 Metro 项目中使用?

我环顾四周,没有发现任何特别有用的东西 - 例如只是 http://social.msdn.microsoft.com/Forums/en-US/winappswithcsharp/thread/88d9b73b-5faa-4204-9d06-dc121e709943.

我尝试将一些 XSD 文件导入 WinRT 项目 - 但这些文件似乎没有生成任何内容.

我真的必须将生成的 xsd 文件从 .Net 移植到 WinRT 吗?:(

我正在导入的模式非常大,而且我有很多使用 XSD 方法的现有代码 - 所以我真的想避免必须手动一次性移植所有这些代码,除非我真的必须...

解决方案

好吧,这个问题很老了,但如果其他人和我有同样的问题/问题,这里有一个(不是完全免费的)解决方案:

>

  1. 下载 xsd2code 插件(https://xsd2code.codeplex.com/)/或使用 VS工具下载器
  2. 注册 15 天试用(您也可以购买)
  3. 在您的项目中导入 .xsd 文件
  4. 右键单击它们(一个接一个)并选择运行 xs2code"
  5. (这是很棒的东西!)作为目标框架选择 WinRT
  6. 生成代码并快乐!

遗憾的是,我只找到了这个工具(只有 15 天的免费试用期)能够做到这一点(为 WinRT/UWP/WinPhone 生成代码)

I'm trying to use some existing C# code in a WinRT (Windows Store/Metro) project.

This code relied on some xml files generated using XSD.

Unfortunately it seems the old XmlDocument classes aren't available in WinRT... there are some alternatives, but they don't seem to be quite the same - so I need to generate some new files for WinRT.

Is there a way to import an XSD file into a WinRT project so that all the data classes, and enums are generated and can be used in the Metro project?

I've looked around and found nothing particularly helpful - e.g. just http://social.msdn.microsoft.com/Forums/en-US/winappswithcsharp/thread/88d9b73b-5faa-4204-9d06-dc121e709943.

I've tried to import some XSD files into WinRT projects - but these don't seem to generate anything.

Do I really have to port the generated xsd files across from .Net to WinRT? :(

The schemas I'm importing are quite large and I have quite a lot of existing code that uses the XSD approach - so I really want to avoid having to do a one-time port of all this code by hand unless I really have to...

解决方案

Ok this question is very old but in case others are having the same question / problem as i did, here is a (not completely free) solution:

  1. Download the xsd2code plugin (https://xsd2code.codeplex.com/) / or with the VS tools downloader
  2. Register for a 15 days trial (you could also buy it)
  3. Import the .xsd files in your project
  4. Right click on them (one after one) and select "run xs2code"
  5. (Here is the awesome stuff!) As target framework choose WinRT
  6. Generate the code and be happy!

Sadly i only found this tool (which has only a free 15 days trial) which was capable for doing this (generating code for WinRT / UWP / WinPhone)

这篇关于在 WinRT 项目中使用 XSD 文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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