如果可能的话,我想以正确的方式做到这一点。我有如下 XML 数据:
<?xml version="1.0" encoding="utf-8"?>
<XnaContent>
<Asset Type="PG2.Dictionary">
<Letters TotalInstances="460100">
<Letter Count="34481">a</Letter>
...
<Letter Count="1361">z</Letter>
</Letters>
<Words Count="60516">
<Word>aardvark</Word>
...
<Word>zebra</Word>
</Words>
</Asset>
</XnaContent>
我想(使用 Content.Load< Dictionary >)将其加载到其中之一
namespace PG2
{
public class Dictionary
{
public class Letters
{
public int totalInstances;
public List<Character> characters;
public class Character
{
public int count;
public char character;
}
}
public class Words
{
public int count;
public HashSet<string> words;
}
Letters letters;
Words words;
}
}
任何人都可以提供说明或教程指针吗?我发现了一些接近但事情似乎在 3.1 和 4.0 之间以我不理解的方式略有变化,并且很多文档都假设我没有知识。到目前为止,我的理解是我需要使 Dictionary 类 Serializable 但我似乎无法做到这一点。我已将 XML 文件添加到内容项目中,但如何让它创建正确的 XNB 文件?
谢谢!查理。