Пример #1
0
 public int Read(BsonReader reader)
 {
     int size = reader.ReadInt32();
     this.Subtype = reader.ReadByte();
     this.Val = reader.ReadBytes(size);
     return this.Size;
 }
Пример #2
0
        public void TestBinary()
        {
            byte[] data = File.ReadAllBytes(@"test-data\tests.binary.txt");
            BsonBinary binaryIn = new BsonBinary(new Binary(data));
            MemoryStream stream = new MemoryStream();
            BsonWriter bsonWriter = new BsonWriter(stream);
            binaryIn.Write(bsonWriter);

            stream.Position = 0;
            BsonReader reader = new BsonReader(stream);
            BsonBinary binaryOut = new BsonBinary();
            int size = reader.ReadInt32();
            binaryOut.Subtype = reader.ReadByte();
            binaryOut.Val = reader.ReadBytes(size);
            Assert.AreEqual(binaryIn.Val, binaryOut.Val);
            Assert.AreEqual(binaryIn.Subtype, binaryOut.Subtype);
            Assert.AreEqual(data.Length, binaryOut.Size);
        }
Пример #3
0
 public int Read(BsonReader reader)
 {
     this.Val = reader.ReadBytes(12);
     return this.Size;
 }