本文整理汇总了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>();
}
示例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);
}
示例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"));
}
}
示例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"));
}
}