2014-02-12 45 views
0

如何反序列化列表或詞典列表? 下面是C#代碼:IntermediateSerializer XNA 4.如何反序列化列表或字典列表?

public enum Values : byte 
{ 
    One, 
    Two, 
    Three, 
    Four 
} 
public class Something 
{ 
    public int Some_int { get; set; } 
} 
public class Test 
{ 
    public List<List<Something>> ListOfSomethingLists { get; set; } 
    public List<Dictionary<Values, Something>> ListOfSomethingDictionaries { get; set; } 
} 

這裏是XML不因爲我的工作不知道如何反序列化:

<?xml version="1.0" encoding="utf-8" ?> 
<XnaContent> 
    <Asset Type="Test"> 
    <ListOfSomethingLists> 
     <Item> 
     <Item> 
      1 
     </Item> 
     <Item> 
      2 
     </Item> 
     </Item> 
     <Item> 
     <Item> 
      3 
     </Item> 
     <Item> 
      4 
     </Item> 
     </Item> 
    </ListOfSomethingLists> 
    <ListOfSomethingDictionaries> 
     <Item> 
     <Item> 
      <Key>One</Key> 
      <Value>1</Value> 
     </Item> 
     <Item> 
      <Key>Two</Key> 
      <Value>2</Value> 
     </Item> 
     </Item> 
     <Item> 
     <Item> 
      <Key>Three</Key> 
      <Value>3</Value> 
     </Item> 
     <Item> 
      <Key>Four</Key> 
      <Value>4</Value> 
     </Item> 
     </Item> 
    </ListOfSomethingDictionaries> 
    </Asset> 
</XnaContent> 

其實我沒有測試這個代碼,但我在我的遊戲中幾乎相同。並仍然困惑如何反序列化列表和字典列表。提前致謝。

+0

你是否已經嘗試過自己。 你以前曾經反序列化過嗎? – MCollard

+0

當然可以。我的遊戲中有很多內容序列化,如加載遊戲關卡,角色,對象等。 – Wallstrider

+0

我可以從我的代碼中顯示100%的工作序列化。 – Wallstrider

回答