Пример #1
0
        public override void ToBson(byte[] buffer, ref int offset)
        {
            int startingOffset = offset;

            // leave space for the size
            offset += 4;

            for (int i = 0; i < _contents.Length; ++i)
            {
                _contents[i].ToBson(i.ToString(), buffer, ref offset);
            }

            // Write the trailing nul
            if (buffer != null)
            {
                buffer[offset] = (byte)0;
            }
            ++offset;

            // Write the completed size
            if (buffer != null)
            {
                SerializationUtilities.Marshall(buffer, ref startingOffset, offset - startingOffset);
            }
        }
Пример #2
0
        public override void ToBson(byte[] buffer, ref int offset)
        {
            int startingOffset = offset;

            // leave space for the size
            offset += 4;

            foreach (DictionaryEntry member in _members)
            {
                ((JProperty)member.Value).ToBson(((JProperty)member.Value).Name, buffer, ref offset);
            }

            // Write the trailing nul
            if (buffer != null)
            {
                buffer[offset] = (byte)0;
            }
            ++offset;

            // Write the completed size
            if (buffer != null)
            {
                SerializationUtilities.Marshall(buffer, ref startingOffset, offset - startingOffset);
            }
        }
Пример #3
0
 public override void ToBson(byte[] buffer, ref int offset)
 {
     if (buffer != null)
     {
         if (this.Value != null)
         {
             SerializationUtilities.Marshall(buffer, ref offset, this.Value);
         }
     }
     else
     {
         offset += this.GetBsonSize();
     }
 }
Пример #4
0
        public byte[] ToBson()
        {
            var size   = this.GetBsonSize("") + 5;
            var buffer = new byte[size];
            int offset = 4;

            this.ToBson("", buffer, ref offset);

            // Write the trailing nul
            buffer[offset++] = (byte)0;

            // Write the completed size
            int zero = 0;

            SerializationUtilities.Marshall(buffer, ref zero, offset);
            return(buffer);
        }