久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

  • <tfoot id='MtqUf'></tfoot>
    1. <i id='MtqUf'><tr id='MtqUf'><dt id='MtqUf'><q id='MtqUf'><span id='MtqUf'><b id='MtqUf'><form id='MtqUf'><ins id='MtqUf'></ins><ul id='MtqUf'></ul><sub id='MtqUf'></sub></form><legend id='MtqUf'></legend><bdo id='MtqUf'><pre id='MtqUf'><center id='MtqUf'></center></pre></bdo></b><th id='MtqUf'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='MtqUf'><tfoot id='MtqUf'></tfoot><dl id='MtqUf'><fieldset id='MtqUf'></fieldset></dl></div>
      <legend id='MtqUf'><style id='MtqUf'><dir id='MtqUf'><q id='MtqUf'></q></dir></style></legend>

      <small id='MtqUf'></small><noframes id='MtqUf'>

        <bdo id='MtqUf'></bdo><ul id='MtqUf'></ul>

      1. 將 XML 反序列化為 XSD 生成的類的問題

        Trouble with XML Deserialization into XSD generated classes(將 XML 反序列化為 XSD 生成的類的問題)
        <legend id='mOAsP'><style id='mOAsP'><dir id='mOAsP'><q id='mOAsP'></q></dir></style></legend>

        <small id='mOAsP'></small><noframes id='mOAsP'>

        <i id='mOAsP'><tr id='mOAsP'><dt id='mOAsP'><q id='mOAsP'><span id='mOAsP'><b id='mOAsP'><form id='mOAsP'><ins id='mOAsP'></ins><ul id='mOAsP'></ul><sub id='mOAsP'></sub></form><legend id='mOAsP'></legend><bdo id='mOAsP'><pre id='mOAsP'><center id='mOAsP'></center></pre></bdo></b><th id='mOAsP'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='mOAsP'><tfoot id='mOAsP'></tfoot><dl id='mOAsP'><fieldset id='mOAsP'></fieldset></dl></div>
              • <bdo id='mOAsP'></bdo><ul id='mOAsP'></ul>

                <tfoot id='mOAsP'></tfoot>

                    <tbody id='mOAsP'></tbody>
                  本文介紹了將 XML 反序列化為 XSD 生成的類的問題的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  限時送ChatGPT賬號..

                  我有一個相當詳細的 xml 文件.下面是頂級節點(我已經包含了橢圓,因為較低級別的節點都格式正確并正確填充了數據):

                  I have a rather detailed xml file. Below is the top level nodes (I have included the ellipse as the lower level nodes are all well formed and properly filled with data):

                  <?xml version="1.0" encoding="UTF-8"?>
                  <config>
                      <Models>...</Models>
                      <Data>...</Data>
                  </config>
                  

                  我已經使用 Visual Studio 2008 命令提示符創建了一個 xsd 文件:

                  I have created an xsd file from using the Visual Studio 2008 command prompt:

                  xsd sample.xml
                  

                  這會生成 xsd 文件就好了.然后我使用以下命令從 xsd 自動生成類:

                  This generates the xsd file just fine. I then auto generate classes from the xsd with the command:

                  xsd sample.xsd /classes
                  

                  為了將xml文件反序列化為類對象,我在helper類中使用了read函數:

                  For the deserialization of the xml file into a class object, I'm using the read function in the helper class:

                  public class XmlSerializerHelper<T>
                  {
                      public Type _type;
                  
                      public XmlSerializerHelper()
                      {
                          _type = typeof(T);
                      }
                  
                      public void Save(string path, object obj)
                      {
                          using (TextWriter textWriter = new StreamWriter(path))
                          {
                              XmlSerializer serializer = new XmlSerializer(_type);
                              serializer.Serialize(textWriter, obj);
                          }
                      }
                  
                      public T Read(string path)
                      {
                          T result;
                          using (TextReader textReader = new StreamReader(path))
                          {
                              XmlSerializer deserializer = new XmlSerializer(_type);
                              result = (T)deserializer.Deserialize(textReader);
                          }
                          return result;
                      }
                  }
                  

                  嘗試反序列化時:

                  var helper = new XmlSerializerHelper<configModels>();
                  var obj = new configModels();
                  obj = helper.Read(filepath);
                  

                  我收到一個錯誤,我推斷是因為反序列化器正在尋找模型"節點,但相應的類名是作為根節點和模型"節點 (configModels) 的組合生成的.為什么生成的類名是這樣的?

                  I receive an error that I have deduced is because the deserializer is looking for the 'Models' node but the corresponding class name was generated as a combination of the root node and the 'Model' node (configModels). Why are the class names generated like this?

                  我嘗試使用以下方法從頂部節點反序列化:

                  I tried to deserialize from the top node using:

                  var helper = new XmlSerializerHelper<config>();
                  var obj = new config();
                  obj = helper.Read(filepath);
                  

                  不幸的是,這會導致一系列錯誤,如下所示:

                  Unfortunately, this the results in a slew of errors like the following:

                  System.InvalidOperationException was unhandled by user code
                  Message="Unable to generate a temporary class (result=1).
                  error CS0030: Cannot convert type 'Application.Lease[]' to 'Application.Lease'
                  error CS0030: Cannot convert type 'Application.CashFlow[]' to 'Application.CashFlow'
                  ...ect.
                  

                  有人可以指導我解決我的 xsd 自動生成可能做錯的地方嗎?

                  Can somebody steer me towards what I might be doing wrong with my xsd auto-generating?

                  推薦答案

                  XSD.EXE 是一個好的開始 - 但它遠非完美.此外,根據您提供的 XML,XSD.EXE 無法始終確定某事物是對象的單個實例,還是對象的開放式數組.

                  XSD.EXE is a good start - but it's far from perfect. Also, based on the XML you provided, XSD.EXE can't always decide for sure whether something is a single instance of an object, or an open-ended array of objects.

                  這似乎是您的兩個元素的情況 - Application.LeaseApplication.CashFlow.它們在生成的 XSD 文件中是如何定義的?這對你有意義嗎?很可能,您必須添加一些提示,例如:

                  This seems to be the case for your two elements - Application.Lease and Application.CashFlow. How are they defined in the generated XSD file? Does that make sense to you? Quite possibly, you'd have to add a little hints, such as:

                  <xs:element name="Lease" minOccurs="0" maxOccurs="1" />
                  

                  對于可選屬性,僅出現 0 次或 1 次.對于 xsd.exe 工具來說,僅基于單個 XML 示例文件,這樣的事情真的很難弄清楚.

                  for an optional property, that's zero or one occurences only. Things like that are really hard for the xsd.exe tool to figure out based on just a single XML sample file.

                  馬克

                  這篇關于將 XML 反序列化為 XSD 生成的類的問題的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

                  【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

                  相關文檔推薦

                  What are good algorithms for vehicle license plate detection?(車牌檢測有哪些好的算法?)
                  onClick event for Image in Unity(Unity中圖像的onClick事件)
                  Running Total C#(運行總 C#)
                  Deleting a directory when clicked on a hyperlink with JAvascript.ASP.NET C#(單擊帶有 JAvascript.ASP.NET C# 的超鏈接時刪除目錄)
                  asp.net listview highlight row on click(asp.net listview 在單擊時突出顯示行)
                  Calling A Button OnClick from a function(從函數調用按鈕 OnClick)
                      <tbody id='wu4IG'></tbody>
                    <i id='wu4IG'><tr id='wu4IG'><dt id='wu4IG'><q id='wu4IG'><span id='wu4IG'><b id='wu4IG'><form id='wu4IG'><ins id='wu4IG'></ins><ul id='wu4IG'></ul><sub id='wu4IG'></sub></form><legend id='wu4IG'></legend><bdo id='wu4IG'><pre id='wu4IG'><center id='wu4IG'></center></pre></bdo></b><th id='wu4IG'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='wu4IG'><tfoot id='wu4IG'></tfoot><dl id='wu4IG'><fieldset id='wu4IG'></fieldset></dl></div>

                      <bdo id='wu4IG'></bdo><ul id='wu4IG'></ul>

                      • <tfoot id='wu4IG'></tfoot>

                      • <legend id='wu4IG'><style id='wu4IG'><dir id='wu4IG'><q id='wu4IG'></q></dir></style></legend>

                            <small id='wu4IG'></small><noframes id='wu4IG'>

                            主站蜘蛛池模板: 亚洲综合一区二区三区 | 四虎影视一区二区 | 亚洲综合免费 | 一级黄色毛片子 | 91亚洲精品国偷拍自产在线观看 | 超黄视频网站 | 亚洲精品成人网 | 在线成人精品视频 | 日韩欧美高清 | 日韩精品二区 | 欧美精品久久久久久 | 成人福利影院 | 亚洲网站免费看 | 日韩一区二区三区视频在线播放 | 欧亚av在线| 精品免费国产视频 | 视频三区| 伊人久久大香线 | 成人av鲁丝片一区二区小说 | 成人亚洲| 伊人婷婷 | 亚洲成人一区二区 | 99精品一区二区 | av在线免费观看网站 | 91av小视频| 国产精品美女一区二区 | 免费一级黄色 | 免费能直接在线观看黄的视频 | 最新日韩在线 | 有码在线| 欧美视频成人 | 久久不卡视频 | 色婷婷精品国产一区二区三区 | 国产日韩欧美一区二区 | 91精品国产乱码久久久 | 国产精品视频一二三区 | 国产一区欧美 | 成人精品福利 | 免费爱爱视频 | 成人亚洲在线 | 日本又色又爽又黄的大片 |