public static byte[] UIntToBytes(ulong value, uint length, Endian endian) { switch (length) { case 1: return(UInt8ToBytes((byte)value)); case 2: return(UInt16ToBytes((ushort)value, endian)); case 4: return(UInt32ToBytes((uint)value, endian)); case 8: return(UInt64ToBytes(value, endian)); default: throw new ArgumentOutOfRangeException(); } }
public static ulong BytesToUInt(byte[] buffer, uint startIndex, uint length, Endian endian) { switch (length) { case 1: return(BytesToUInt8(buffer, startIndex)); case 2: return(BytesToUInt16(buffer, startIndex, endian)); case 4: return(BytesToUInt32(buffer, startIndex, endian)); case 8: return(BytesToUInt64(buffer, startIndex, endian)); default: throw new ArgumentOutOfRangeException(); } }
public static byte[] Int16ToBytes(short value, Endian endian) { return(endian == Endian.Little ? Int16ToBytesLE(value) : Int16ToBytesBE(value)); }
public static byte[] UInt8ToBytes(byte value, Endian endian) { return(new byte[] { value }); }
public static ulong BytesToUInt64(byte[] buffer, uint startIndex, Endian endian) { return(endian == Endian.Little ? BytesToUInt64LE(buffer, startIndex) : BytesToUInt64BE(buffer, startIndex)); }
public static uint BytesToUInt32(byte[] buffer, uint startIndex, Endian endian) { return(endian == Endian.Little ? BytesToUInt32LE(buffer, startIndex) : BytesToUInt32BE(buffer, startIndex)); }
public static ushort BytesToUInt16(byte[] buffer, uint startIndex, Endian endian) { return(endian == Endian.Little ? BytesToUInt16LE(buffer, startIndex) : BytesToUInt16BE(buffer, startIndex)); }
public static byte BytesToUInt8(byte[] buffer, uint startIndex, Endian endian) { return(buffer[startIndex]); }
public static bool BytesToBool(byte[] buffer, uint startIndex, uint length, Endian endian) { return(endian == Endian.Little ? BytesToBoolLE(buffer, startIndex, length) : BytesToBoolBE(buffer, startIndex, length)); }
public static byte[] Int8ToBytes(sbyte value, Endian endian) { return(new byte[] { (byte)value }); }
public static byte[] UInt64ToBytes(ulong value, Endian endian) { return(endian == Endian.Little ? UInt64ToBytesLE(value) : UInt64ToBytesBE(value)); }
public static byte[] BoolToBytes(bool value, uint length, Endian endian) { return(endian == Endian.Little ? BoolToBytesLE(value, length) : BoolToBytesBE(value, length)); }