Exemplo n.º 1
0
        /// <summary>
        /// Serializes a new bond value to an old bond blob
        /// </summary>
        /// <typeparam name="T">the type of the value</typeparam>
        /// <param name="value">the new bond value</param>
        /// <param name="bufferProvider">the buffer provider which provides buffers used during serialization</param>
        /// <returns>the old bond blow representing the new bond value</returns>
        public static Microsoft.Bond.BondBlob ToBlob <T>(T value, IBufferProvider bufferProvider)
        {
            OutputBuffer buffer        = bufferProvider.GetOutputBuffer();
            var          startPosition = buffer.Position;
            CompactBinaryWriter <OutputBuffer> writer = new CompactBinaryWriter <OutputBuffer>(buffer);

            Serialize.To(writer, value);
            bufferProvider.ReleaseOutputBuffer();
            return(new Microsoft.Bond.BondBlob(buffer.Data.Array, (int)startPosition, (int)(buffer.Position - startPosition)));
        }