コード例 #1
0
        public static void WriteValueU8(this Stream stream, byte value)
        {
            var data = SmallWorkBuffer.Get(1);

            data[0] = value;
            stream.Write(data, 0, 1);
        }
コード例 #2
0
ファイル: Guid.cs プロジェクト: rootCBR/DriveConverter
        public static Guid ReadValueGuid(this Stream stream, Endian endian)
        {
            var a = stream.ReadValueS32(endian);
            var b = stream.ReadValueS16(endian);
            var c = stream.ReadValueS16(endian);
            var d = SmallWorkBuffer.ReadBytes(stream, 8);

            return(new Guid(a, b, c, d));
        }
コード例 #3
0
        public static uint ReadValueU32(this Stream stream, Endian endian)
        {
            var data  = SmallWorkBuffer.ReadBytes(stream, 4);
            var value = BitConverter.ToUInt32(data, 0);

            if (ShouldSwap(endian) == true)
            {
                value = value.Swap();
            }
            return(value);
        }
コード例 #4
0
        public static void WriteValueU16(this Stream stream, ushort value, Endian endian)
        {
            if (ShouldSwap(endian) == true)
            {
                value = value.Swap();
            }
            var data = SmallWorkBuffer.Get(2);

            data[0] = (byte)((value & 0x00FFu) >> 0);
            data[1] = (byte)((value & 0xFF00u) >> 8);
            stream.Write(data, 0, 2);
        }
コード例 #5
0
        public static void WriteValueU64(this Stream stream, ulong value, Endian endian)
        {
            if (ShouldSwap(endian) == true)
            {
                value = value.Swap();
            }
            var data   = SmallWorkBuffer.Get(8);
            var valuea = (uint)value;
            var valueb = (uint)(value >> 32);

            data[0] = (byte)((valuea & 0x000000FFu) >> 0);
            data[1] = (byte)((valuea & 0x0000FF00u) >> 8);
            data[2] = (byte)((valuea & 0x00FF0000u) >> 16);
            data[3] = (byte)((valuea & 0xFF000000u) >> 24);
            data[4] = (byte)((valueb & 0x000000FFu) >> 0);
            data[5] = (byte)((valueb & 0x0000FF00u) >> 8);
            data[6] = (byte)((valueb & 0x00FF0000u) >> 16);
            data[7] = (byte)((valueb & 0xFF000000u) >> 24);
            stream.Write(data, 0, 8);
        }
コード例 #6
0
 public static byte ReadValueU8(this Stream stream)
 {
     return(SmallWorkBuffer.ReadBytes(stream, 1)[0]);
 }