Ejemplo n.º 1
0
        /// <summary>
        /// The SetJson.
        /// </summary>
        /// <param name="thdr">The thdr<see cref="DealHeader"/>.</param>
        /// <param name="tostream">The tostream<see cref="Stream"/>.</param>
        /// <returns>The <see cref="int"/>.</returns>
        public static int SetJson(this DealHeader thdr, Stream tostream)
        {
            BinaryWriter binwriter = new BinaryWriter(tostream);

            binwriter.Write(thdr.SetJsonString());
            return((int)tostream.Length);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// The SetJson.
        /// </summary>
        /// <param name="thdr">The thdr<see cref="DealHeader"/>.</param>
        /// <param name="buffer">The buffer<see cref="ISerialBuffer"/>.</param>
        /// <param name="offset">The offset<see cref="int"/>.</param>
        /// <returns>The <see cref="int"/>.</returns>
        public static int SetJson(this DealHeader thdr, ISerialBuffer buffer, int offset = 0)
        {
            if (offset > 0)
            {
                byte[] jsonBytes   = Encoding.UTF8.GetBytes(thdr.SetJsonString());
                byte[] serialBytes = new byte[jsonBytes.Length + offset];
                jsonBytes.CopyTo(serialBytes, offset);
                buffer.SerialBlock = serialBytes;
                jsonBytes          = null;
            }
            else
            {
                buffer.SerialBlock = Encoding.UTF8.GetBytes(thdr.SetJsonString());
            }

            return(buffer.SerialBlock.Length);
        }
Ejemplo n.º 3
0
 /// <summary>
 /// The SetJson.
 /// </summary>
 /// <param name="thdr">The thdr<see cref="DealHeader"/>.</param>
 /// <param name="stringbuilder">The stringbuilder<see cref="StringBuilder"/>.</param>
 /// <returns>The <see cref="int"/>.</returns>
 public static int SetJson(this DealHeader thdr, StringBuilder stringbuilder)
 {
     stringbuilder.AppendLine(thdr.SetJsonString());
     return(stringbuilder.Length);
 }