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

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

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

    1. <tfoot id='SxcTp'></tfoot>

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

        • <bdo id='SxcTp'></bdo><ul id='SxcTp'></ul>

        xmlserializer 驗證

        xmlserializer validation(xmlserializer 驗證)

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

          • <bdo id='Wflqx'></bdo><ul id='Wflqx'></ul>

            <tfoot id='Wflqx'></tfoot>

            1. <i id='Wflqx'><tr id='Wflqx'><dt id='Wflqx'><q id='Wflqx'><span id='Wflqx'><b id='Wflqx'><form id='Wflqx'><ins id='Wflqx'></ins><ul id='Wflqx'></ul><sub id='Wflqx'></sub></form><legend id='Wflqx'></legend><bdo id='Wflqx'><pre id='Wflqx'><center id='Wflqx'></center></pre></bdo></b><th id='Wflqx'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='Wflqx'><tfoot id='Wflqx'></tfoot><dl id='Wflqx'><fieldset id='Wflqx'></fieldset></dl></div>
                    <tbody id='Wflqx'></tbody>
                  <legend id='Wflqx'><style id='Wflqx'><dir id='Wflqx'><q id='Wflqx'></q></dir></style></legend>
                  本文介紹了xmlserializer 驗證的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  限時送ChatGPT賬號..

                  我正在使用 XmlSerializer 反序列化 Xml 檔案.但我發現生成的類 xsd.exe 只提供讀取 xml 的能力,但沒有驗證.例如,如果文檔中缺少一個節點,則生成的類的屬性字段將為空,而不是像我預期的那樣拋出驗證異常.我怎樣才能做到這一點?謝謝!

                  I'm using XmlSerializer to deserialize Xml achives. But I found the class xsd.exe generated only offers capability to read the xml, but no validation. For example, if one node is missing in a document, the attribute field of the generated class will be null, rather than throws a validation exception as I expected. How can I achieve that? Thanks!

                  推薦答案

                  以下代碼應在反序列化時針對架構進行驗證.類似的代碼可用于在序列化時針對模式進行驗證.

                  The following code should validate against a schema while deserializing. Similar code can be used to validate against a schema while serializing.

                  private static Response DeserializeAndValidate(string tempFileName)
                  {
                      XmlSchemaSet schemas = new XmlSchemaSet();
                      schemas.Add(LoadSchema());
                  
                      Exception firstException = null;
                  
                      var settings = new XmlReaderSettings
                                     {
                                         Schemas = schemas,
                                         ValidationType = ValidationType.Schema,
                                         ValidationFlags =
                                             XmlSchemaValidationFlags.ProcessIdentityConstraints |
                                             XmlSchemaValidationFlags.ReportValidationWarnings
                                     };
                      settings.ValidationEventHandler +=
                          delegate(object sender, ValidationEventArgs args)
                          {
                              if (args.Severity == XmlSeverityType.Warning)
                              {
                                  Console.WriteLine(args.Message);
                              }
                              else
                              {
                                  if (firstException == null)
                                  {
                                      firstException = args.Exception;
                                  }
                  
                                  Console.WriteLine(args.Exception.ToString());
                              }
                          };
                  
                      Response result;
                      using (var input = new StreamReader(tempFileName))
                      {
                          using (XmlReader reader = XmlReader.Create(input, settings))
                          {
                              XmlSerializer ser = new XmlSerializer(typeof (Response));
                              result = (Response) ser.Deserialize(reader);
                          }
                      }
                  
                      if (firstException != null)
                      {
                          throw firstException;
                      }
                  
                      return result;
                  }
                  

                  這篇關于xmlserializer 驗證的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持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)

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

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

                          • <bdo id='TKa2Q'></bdo><ul id='TKa2Q'></ul>
                            <tfoot id='TKa2Q'></tfoot>

                          • 主站蜘蛛池模板: 永久免费视频 | 国产精品视频偷伦精品视频 | 欧美a v在线 | 91精品国产91久久久久久 | 国产精品久久久久久婷婷天堂 | 人人做人人澡人人爽欧美 | 四虎成人av | 欧美高清一区 | 综合久久久 | 午夜免费精品视频 | 午夜久久av | 日本天天操 | 鲁一鲁资源影视 | 欧美精品99 | 久久新视频 | 国产成人久久av免费高清密臂 | 欧美xxxx黑人又粗又长 | 成人在线免费网站 | 天天曰天天干 | avmans最新导航地址 | 亚洲最大的成人网 | 最近中文字幕第一页 | 亚洲欧美视频 | 中文字幕亚洲视频 | 亚洲高清在线 | 国产有码 | 欧美精品在线免费 | 欧美黄在线观看 | 91se在线| 不卡一二三区 | 免费网站在线 | 国产精品美女久久久免费 | 亚洲视频一| 黄色日本片 | 久久精品影视 | 天天天操操操 | 一区二区国产在线 | 久久久久99 | 免费播放一级片 | 欧美久久久久久久久 | 亚洲精品一区二区 |