Example #1
0
 public int Read(BsonReader reader)
 {
     int size = reader.ReadInt32();
     this.Subtype = reader.ReadByte();
     this.Val = reader.ReadBytes(size);
     return this.Size;
 }
Example #2
0
 public int Read(BsonReader reader)
 {
     sbyte typeNum = (sbyte)reader.ReadByte();
     int bytesRead;
     this.Name = reader.ReadString();
     this.Val = BsonConvert.Create((BsonDataType)typeNum);
     bytesRead = this.Val.Read(reader);
     bytesRead += (1 + this.Name.Length + 1); //type byte & name + term
     return bytesRead;
 }
Example #3
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);
        }