IntermediateSerializer XNA 4. How do I deserialize List of lists or List of dictionaries?

白昼怎懂夜的黑 提交于 2019-12-25 02:56:17

问题


How do I deserialize List of lists or List of dictionaries? Here is C# code:

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; }
}

And here is XML which doesn't work cuz I don't know how to deserialize it:

    <?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>

I actually didn't test this code but I have almost the same in my game. And still confused how to deserialize list of lists and list of dictionaries. Thanks in advance.


回答1:


With this explanation you should be possible to solve your problem.

http://xboxforums.create.msdn.com/forums/p/70599/614469.aspx

little example.

    [assembly: SecurityTransparent] 
    namespace randomnamespace
    { 
        public class randomclass
        { 

        } 
    }


来源:https://stackoverflow.com/questions/21729053/intermediateserializer-xna-4-how-do-i-deserialize-list-of-lists-or-list-of-dict

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!