public static void WriteUInt64(this BinaryWriter bw, ulong value, FieldStructureEntry map = null) { if (map == null) { bw.Write(value); } else { bw.Write(BitConverter.GetBytes(value), 0, map.ByteCount); } }
public static ulong ReadUInt64(this BinaryReader br, FieldStructureEntry map = null) { if (map == null) { return(br.ReadUInt64()); } byte[] b = new byte[sizeof(ulong)]; for (int i = 0; i < map.ByteCount; i++) { b[i] = br.ReadByte(); } return(BitConverter.ToUInt64(b, 0)); }
public static uint ReadUInt32(this BinaryReader br, FieldStructureEntry map = null) { if (map == null) { return(br.ReadUInt32()); } var b = new byte[sizeof(uint)]; for (var i = 0; i < map.ByteCount; i++) { b[i] = br.ReadByte(); } return(BitConverter.ToUInt32(b, 0)); }
public void SetLength(FieldStructureEntry nextField) { this.Length = Math.Max(1, (int)Math.Floor((nextField.Offset - this.Offset) / (double)this.ByteCount)); }