Пример #1
0
 public static byte[] ConvertInt64(Int64 value, ByteEndianess byteEndianess = ByteEndianess.LittleEndian, BitEndianess bitEndianess = BitEndianess.Msb)
 {
     byte[] buffer = new byte[8];
     if (ByteEndianess.BigEndian == byteEndianess)
     {
         buffer[0] = ((Byte)(value >> 56));
         buffer[1] = ((Byte)(value >> 48));
         buffer[2] = ((Byte)(value >> 40));
         buffer[3] = ((Byte)(value >> 32));
         buffer[4] = ((Byte)(value >> 24));
         buffer[5] = ((Byte)(value >> 16));
         buffer[6] = ((Byte)(value >> 8));
         buffer[7] = ((Byte)value);
     }
     else
     {
         buffer[0] = ((Byte)value);
         buffer[1] = ((Byte)(value >> 8));
         buffer[2] = ((Byte)(value >> 16));
         buffer[3] = ((Byte)(value >> 24));
         buffer[4] = ((Byte)(value >> 32));
         buffer[5] = ((Byte)(value >> 40));
         buffer[6] = ((Byte)(value >> 48));
         buffer[7] = ((Byte)(value >> 56));
     }
     return(buffer);
 }
Пример #2
0
 public static byte[] ConvertInt16(Int16 value, ByteEndianess byteEndianess = ByteEndianess.LittleEndian, BitEndianess bitEndianess = BitEndianess.Msb)
 {
     byte[] buffer = new byte[2];
     if (ByteEndianess.BigEndian == byteEndianess)
     {
         buffer[0] = ((Byte)(value >> 8));
         buffer[1] = ((Byte)value);
     }
     else
     {
         buffer[0] = ((Byte)value);
         buffer[1] = ((Byte)(value >> 8));
     }
     return(buffer);
 }
Пример #3
0
 public static byte[] ConvertUInt32(UInt32 value, ByteEndianess byteEndianess = ByteEndianess.LittleEndian, BitEndianess bitEndianess = BitEndianess.Msb)
 {
     byte[] buffer = new byte[4];
     if (ByteEndianess.BigEndian == byteEndianess)
     {
         buffer[0] = ((Byte)(value >> 24));
         buffer[1] = ((Byte)(value >> 16));
         buffer[2] = ((Byte)(value >> 8));
         buffer[3] = ((Byte)value);
     }
     else
     {
         buffer[0] = ((Byte)value);
         buffer[1] = ((Byte)(value >> 8));
         buffer[2] = ((Byte)(value >> 16));
         buffer[3] = ((Byte)(value >> 24));
     }
     return(buffer);
 }
Пример #4
0
 public BinaryParser(Stream stream, ByteEndianess byteEndianess, BitEndianess bitEndianess) : this(stream)
 {
     myByteEndianess = byteEndianess;
     myBitEndianess  = bitEndianess;
 }
Пример #5
0
 public BinaryParser(Byte[] data, ByteEndianess byteEndianess)
     : this(data)
 {
     myByteEndianess = byteEndianess;
 }
Пример #6
0
 public BinaryParser(ByteEndianess byteEndianess, BitEndianess bitEndianess) : this()
 {
     myByteEndianess = byteEndianess;
     myBitEndianess  = bitEndianess;
 }