久久久久久久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久久久精品国产一区二区蜜臀 | 国内精品99| 日本天天操 | 天天操夜夜爽 | 国产激情91久久精品导航 | 五月综合激情网 | av中文字幕在线播放 | 日韩成人av在线播放 | 三a毛片| 99精品在线观看 | 久久国产精品-国产精品 | 黄色av网站免费看 | 国产高清在线观看 | 日韩一区二区三区在线 | 久久777| 男女羞羞视频在线观看 | 国产a级毛毛片 | 一级一片在线观看 | 国产成人精品一区二区三区四区 | 国产91亚洲精品 | 欧美xxxx色视频在线观看免费 | 欧美一区二区三区在线观看视频 | 欧美黄在线观看 | 国产美女自拍视频 | 狠狠av | 国产免费一区二区 | 久久青| 一区二区免费高清视频 | www.欧美 | 欧美激情视频一区二区三区在线播放 | 国内精品视频一区二区三区 | 91在线网站 | 小h片免费观看久久久久 | 精品久久久久久久久久久久久久 | 精品久久久久久亚洲精品 | 女生羞羞网站 | 日韩av在线免费 |