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

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

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

      1. Dictionary&lt;Key, Value&gt; 上 .NET 二進制序列化

        Strange behaviour of .NET binary serialization on Dictionarylt;Key, Valuegt;(Dictionarylt;Key, Valuegt; 上 .NET 二進制序列化的奇怪行為)
            <legend id='aAhqD'><style id='aAhqD'><dir id='aAhqD'><q id='aAhqD'></q></dir></style></legend>
            <tfoot id='aAhqD'></tfoot>
          1. <i id='aAhqD'><tr id='aAhqD'><dt id='aAhqD'><q id='aAhqD'><span id='aAhqD'><b id='aAhqD'><form id='aAhqD'><ins id='aAhqD'></ins><ul id='aAhqD'></ul><sub id='aAhqD'></sub></form><legend id='aAhqD'></legend><bdo id='aAhqD'><pre id='aAhqD'><center id='aAhqD'></center></pre></bdo></b><th id='aAhqD'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='aAhqD'><tfoot id='aAhqD'></tfoot><dl id='aAhqD'><fieldset id='aAhqD'></fieldset></dl></div>
              <bdo id='aAhqD'></bdo><ul id='aAhqD'></ul>

                    <tbody id='aAhqD'></tbody>
                • <small id='aAhqD'></small><noframes id='aAhqD'>

                  本文介紹了Dictionary&lt;Key, Value&gt; 上 .NET 二進制序列化的奇怪行為的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  限時送ChatGPT賬號..

                  我在 .NET 的二進制序列化中遇到了一個奇怪的行為,至少在我的預期中.

                  I encountered a, at least to my expectations, strange behavior in the binary serialization of .NET.

                  Dictionary 的所有項目在 OnDeserialization 回調之后被添加到它們的父項.相比之下,List 則相反.這在現實世界的存儲庫代碼中可能真的很煩人,例如當您需要向字典項添加一些委托時.請檢查示例代碼并觀察斷言.

                  All items of a Dictionary that are loaded are added to their parent AFTER the OnDeserialization callback. In contrast List does the other way. This can be really annoying in real world repository code, for example when you need to add some delegates to dictionary items. Please check the example code and watch the asserts.

                  這是正常行為嗎?

                  [Serializable]
                  public class Data : IDeserializationCallback
                  {
                      public List<string> List { get; set; }
                  
                      public Dictionary<string, string> Dictionary { get; set; }
                  
                      public Data()
                      {
                          Dictionary = new Dictionary<string, string> { { "hello", "hello" }, { "CU", "CU" } };
                          List = new List<string> { "hello", "CU" };
                      }
                  
                      public static Data Load(string filename)
                      {
                          using (Stream stream = File.OpenRead(filename))
                          {
                              Data result = (Data)new BinaryFormatter().Deserialize(stream);
                              TestsLengthsOfDataStructures(result);
                  
                              return result;
                          }
                      }
                  
                      public void Save(string fileName)
                      {
                          using (Stream stream = File.Create(fileName))
                          {
                              new BinaryFormatter().Serialize(stream, this);
                          }
                      }
                  
                      public void OnDeserialization(object sender)
                      {
                          TestsLengthsOfDataStructures(this);
                      }
                  
                      private static void TestsLengthsOfDataStructures(Data data)
                      {
                          Debug.Assert(data.List.Count == 2, "List");
                          Debug.Assert(data.Dictionary.Count == 2, "Dictionary");
                      }
                  }
                  

                  推薦答案

                  我可以重現問題.環顧谷歌,發現:http://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=94265 雖然我不確定這是完全相同的問題,但看起來非常相似.

                  I can reproduce the problem. Had a look around Google and found this: http://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=94265 although I'm not sure it's the exact same problem, it seems pretty similar.

                  我認為添加此代碼可能會解決問題?

                  I think that adding this code may have fixed the problem?

                      public void OnDeserialization(object sender)
                      {
                              this.Dictionary.OnDeserialization(sender);
                      }
                  

                  沒有時間進行詳盡的測試,我想擊敗 Marc 得到答案 ;-)

                  No time to exhaustively test, and I want to beat Marc to the answer ;-)

                  這篇關于Dictionary&lt;Key, Value&gt; 上 .NET 二進制序列化的奇怪行為的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持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)
                    <tfoot id='bB3SL'></tfoot>

                      <tbody id='bB3SL'></tbody>

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

                      <legend id='bB3SL'><style id='bB3SL'><dir id='bB3SL'><q id='bB3SL'></q></dir></style></legend>
                    1. <small id='bB3SL'></small><noframes id='bB3SL'>

                            <bdo id='bB3SL'></bdo><ul id='bB3SL'></ul>
                          • 主站蜘蛛池模板: 日韩av成人 | 日本特黄a级高清免费大片 国产精品久久性 | 视频一区欧美 | 中文字幕一区二区三区精彩视频 | 国产成人一区二区 | 无码一区二区三区视频 | 欧美二区三区 | 欧美日韩在线观看视频网站 | 日本不卡一区二区三区在线观看 | 99视频免费播放 | 成人在线视频免费观看 | 欧美成人在线免费 | 国产日韩久久 | 天天综合网91 | 无码日韩精品一区二区免费 | 亚洲成人av一区二区 | 嫩草研究影院 | 国产精品日本一区二区不卡视频 | 日韩成人免费视频 | 91久久国产综合久久 | 欧美精品一区二区三区在线 | 国产一区二区电影 | 丝袜一区二区三区 | 成人精品一区亚洲午夜久久久 | 日本电影韩国电影免费观看 | 一区二区三区成人 | 日韩专区中文字幕 | 91免费看片 | 91国内精品久久 | 一区二区三区在线 | 欧美视频二区 | 成人免费网站www网站高清 | 一区二区三区小视频 | 久久乐国产精品 | 久久精彩视频 | 亚洲精品黄色 | 亚洲一区在线日韩在线深爱 | 中文字幕免费视频 | 中文字幕乱码一区二区三区 | 久久成人国产 | 国产精品99久久久久久久久久久久 |