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


C# Decoder.Decode方法代码示例

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


在下文中一共展示了Decoder.Decode方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Main

        static void Main(string[] args)
        {
            ModelManager.Add(typeof(LoginMsg), delegate() { return new LoginMsg(); });
            Person person = new Person();
            person.id = 10;
            person.name = "一阿萨德法萨芬";
            person.addr = "沃尔沃人情味儿阿是否是";

            LoginMsg msg = new LoginMsg();
            msg.id = 1;
            msg.name = "asdfasdfasfasasdfsadfsadfsafsaf";
            msg.info = person;
            msg.infos.Add(person);

            MemoryStream stream = new MemoryStream();
            Encoder encoder = new Encoder(stream);
            encoder.Encode(msg);

            Decoder decoder = new Decoder(stream);
            LoginMsg result = decoder.Decode<LoginMsg>();
        }
开发者ID:jeckbjy,项目名称:proto,代码行数:21,代码来源:Program.cs

示例2: Decode_CorrectlyDecodesInstructions

        public void Decode_CorrectlyDecodesInstructions(UInt64 raw, InstructionType expectedOp, Int32 expecteOperand)
        {
            // Arrange
            var decoder = new Decoder();

            // Act
            var instruction = decoder.Decode(raw);

            // Assert
            instruction.Type.Should().Be(expectedOp);
            instruction.Operand.Should().Be(expecteOperand);
        }
开发者ID:hkra,项目名称:Computer,代码行数:12,代码来源:DecoderTests.cs

示例3: TestWithPointers

        public void TestWithPointers()
        {
            var path = Path.Combine("..", "..", "TestData", "MaxMind-DB", "test-data", "maps-with-pointers.raw");
            using (var database = new ArrayReader(path))
            {
                var decoder = new Decoder(database, 0);

                var node = decoder.Decode(0).Node;
                Assert.That(node.Value<string>("long_key"), Is.EqualTo("long_value1"));

                node = decoder.Decode(22).Node;
                Assert.That(node.Value<string>("long_key"), Is.EqualTo("long_value2"));

                node = decoder.Decode(37).Node;
                Assert.That(node.Value<string>("long_key2"), Is.EqualTo("long_value1"));

                node = decoder.Decode(50).Node;
                Assert.That(node.Value<string>("long_key2"), Is.EqualTo("long_value2"));

                node = decoder.Decode(55).Node;
                Assert.That(node.Value<string>("long_key"), Is.EqualTo("long_value1"));

                node = decoder.Decode(57).Node;
                Assert.That(node.Value<string>("long_key2"), Is.EqualTo("long_value2"));
            }
        }
开发者ID:RalphSim,项目名称:MaxMind-DB-Reader-dotnet,代码行数:26,代码来源:PointerTest.cs

示例4: TestWithPointers

        public void TestWithPointers()
        {
            var path = Path.Combine(new[] { "..", "..", "TestData", "MaxMind-DB", "test-data", "maps-with-pointers.raw" });
            var stream = new ThreadLocal<Stream>(() => new MemoryStream(File.ReadAllBytes(path)));
            using (stream)
            {
                var decoder = new Decoder(stream, 0);

                var node = decoder.Decode(0).Node;
                Assert.That(node.Value<string>("long_key"), Is.EqualTo("long_value1"));

                node = decoder.Decode(22).Node;
                Assert.That(node.Value<string>("long_key"), Is.EqualTo("long_value2"));

                node = decoder.Decode(37).Node;
                Assert.That(node.Value<string>("long_key2"), Is.EqualTo("long_value1"));

                node = decoder.Decode(50).Node;
                Assert.That(node.Value<string>("long_key2"), Is.EqualTo("long_value2"));

                node = decoder.Decode(55).Node;
                Assert.That(node.Value<string>("long_key"), Is.EqualTo("long_value1"));

                node = decoder.Decode(57).Node;
                Assert.That(node.Value<string>("long_key2"), Is.EqualTo("long_value2"));
            }
        }
开发者ID:Wolfium,项目名称:MaxMind-DB-Reader-dotnet,代码行数:27,代码来源:PointerTest.cs


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