Ejemplo n.º 1
0
 /// <summary>
 /// Converts this value to its byte array representation in little-endian order
 /// and writes the result to the given <see cref="FastStream"/>.
 /// </summary>
 /// <param name="stream">Stream to use.</param>
 public void WriteToStream(FastStream stream)
 {
     if (value <= 252) // 1 Byte
     {
         stream.Write((byte)value);
     }
     else if (value <= 0xffff) // 1 + 2 Byte
     {
         stream.Write((byte)0xfd);
         stream.Write((ushort)value);
     }
     else if (value <= 0xffffffff) // 1 + 4 Byte
     {
         stream.Write((byte)0xfe);
         stream.Write((uint)value);
     }
     else // < 0xffffffffffffffff // 1 + 8 Byte
     {
         stream.Write((byte)0xff);
         stream.Write(value);
     }
 }
 /// <summary>
 /// Converts this value to its byte array representation in little-endian order
 /// and writes the result to the given <see cref="FastStream"/>.
 /// </summary>
 /// <param name="stream">Stream to use.</param>
 public void WriteToStream(FastStream stream)
 {
     if (value < (byte)OP.PushData1)
     {
         stream.Write((byte)value);
     }
     else if (value <= byte.MaxValue)
     {
         stream.Write((byte)OP.PushData1);
         stream.Write((byte)value);
     }
     else if (value <= ushort.MaxValue)
     {
         stream.Write((byte)OP.PushData2);
         stream.Write((ushort)value);
     }
     else // Value <= uint.MaxValue
     {
         stream.Write((byte)OP.PushData4);
         stream.Write(value);
     }
 }
Ejemplo n.º 3
0
 /// <summary>
 /// Converts this value to its byte array representation in little-endian order
 /// and writes the result to the given <see cref="FastStream"/>.
 /// </summary>
 /// <param name="stream">Stream to use.</param>
 public void WriteToStream(FastStream stream)
 {
     stream.Write(value);
 }