internal static string ReadString(Byte[] buffer, int offset)
        {
            int str_size = BitHelper.ToInt32(buffer, offset);

            offset += 4;
            return(GetString(buffer, offset, str_size));
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Returns a decimal value converted from 16 bytes at a specified position in a byte array.
 /// </summary>
 /// <param name="buffer">An array of bytes.</param>
 /// <param name="startIndex">The starting position within the buffer.</param>
 /// <returns>A decimal value.</returns>
 public static decimal GetDecimal(byte[] buffer, int startIndex)
 {
     int[] int_array = new int[4];
     for (int i = 0; i < 4; i++)
     {
         int_array[i] = BitHelper.ToInt32(buffer, startIndex + (i << 2));
     }
     return(new decimal(int_array));
 }
        internal static string ReadString(MemoryStream ms)
        {
            byte[] int_bytes = new byte[4];
            ms.Read(int_bytes, 0, 4);
            int str_size = BitHelper.ToInt32(int_bytes, 0);

            byte[] str_buff = new byte[str_size];
            ms.Read(str_buff, 0, str_size);
            return(GetString(str_buff));
        }
Ejemplo n.º 4
0
 /// <summary>
 /// Writes an IPEndPoint instance to the specified buffer.
 /// </summary>
 /// <param name="ipe">An IPEndPoint instance.</param>
 /// <param name="buffer">The buffer to write the ipe in.</param>
 public unsafe static void WriteIPEndPoint(IPEndPoint ipe, byte *buffer)
 {
     *(int *)buffer       = BitHelper.ToInt32(ipe.Address.GetAddressBytes(), 0);
     *(int *)(buffer + 4) = ipe.Port;
 }