当前位置: 首页>>代码示例>>C#>>正文


C# Unpacker.UnpackListOfObjects方法代码示例

本文整理汇总了C#中Unpacker.UnpackListOfObjects方法的典型用法代码示例。如果您正苦于以下问题:C# Unpacker.UnpackListOfObjects方法的具体用法?C# Unpacker.UnpackListOfObjects怎么用?C# Unpacker.UnpackListOfObjects使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Unpacker的用法示例。


在下文中一共展示了Unpacker.UnpackListOfObjects方法的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));
            }
        }
开发者ID:Keith-Redding,项目名称:msgpack,代码行数:38,代码来源:TestFileReading.cs


注:本文中的Unpacker.UnpackListOfObjects方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。