本文整理汇总了C#中Unpacker.UnpackDictionary方法的典型用法代码示例。如果您正苦于以下问题:C# Unpacker.UnpackDictionary方法的具体用法?C# Unpacker.UnpackDictionary怎么用?C# Unpacker.UnpackDictionary使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Unpacker
的用法示例。
在下文中一共展示了Unpacker.UnpackDictionary方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestReadFromFile
public void TestReadFromFile()
{
using (var stream = new FileStream(@"TestFiles\test.mpac", FileMode.Open))
{
var unpacker = new Unpacker(stream);
Assert.AreEqual(
new List<long>
{
0, 1, -1, -123, 12345678, -31, -128, -65535, -(1L << 16), -(1L << 24), 31, 255, 256, (1L << 16),
(1L << 24), (1L << 32)
}, unpacker.UnpackListOfObjects());
Assert.AreEqual(
new List<double>
{
0.0, -0.0, 1.0, -1.0, 3.40282347E+38, -3.40282347E+38, 1.7976931348623157E+308, -1.7976931348623157E+308,
double.NaN, double.PositiveInfinity, double.NegativeInfinity
}, unpacker.UnpackListOfObjects());
Assert.AreEqual(0xffffffffffffffff, unpacker.UnpackULong());
Assert.AreEqual(null, unpacker.UnpackNull());
Assert.AreEqual(true, unpacker.UnpackBool());
Assert.AreEqual(false, unpacker.UnpackBool());
Assert.AreEqual(Enumerable.Range(1, 65535).ToList(), unpacker.UnpackListOfObjects());
Assert.AreEqual(Enumerable.Range(1, 66000).ToList(), unpacker.UnpackListOfObjects());
TestPackUnpack.AssertDictionariesEqual(
new Dictionary<int, bool> {{1, true}, {10, false}, {-127, true}}, unpacker.UnpackDictionary());
TestPackUnpack.AssertDictionariesEqual(
Enumerable.Range(1, 65536).ToDictionary(v => v, v => v * 2), unpacker.UnpackDictionary());
TestPackUnpack.AssertDictionariesEqual(
new Dictionary<int, string> { { 1, "qwerty" }, { 2, "zxc" }, { 5, "" }, {6, null} }, UnpackDictionary(unpacker));
}
}