IntermediateSerializer XNA 4. 如何反序列化列表列表或字典列表? [英] IntermediateSerializer XNA 4. How do I deserialize List of lists or List of dictionaries?

查看:19
本文介绍了IntermediateSerializer XNA 4. 如何反序列化列表列表或字典列表?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何反序列化列表列表或字典列表?这是 C# 代码:

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

这里的 XML 不起作用,因为我不知道如何反序列化它:

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.

推荐答案

有了这个解释,你应该可以解决你的问题.

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

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

小例子.

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

        } 
    }

这篇关于IntermediateSerializer XNA 4. 如何反序列化列表列表或字典列表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆