Using XSD files in WinRT Projects

这一生的挚爱 提交于 2019-12-24 15:32:45

问题


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


回答1:


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)



来源:https://stackoverflow.com/questions/12770817/using-xsd-files-in-winrt-projects

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