public override double GetDouble() { var c = _accessor.ReadDouble(Position); Position += 4; //conform to how the index was written return(Number.FlipEndian(c)); }
public override double GetDouble() { var littleEndian = _accessor.ReadDouble(Ix(NextGetIndex(8))); if (bigEndian) { return(Number.FlipEndian(littleEndian)); } return(littleEndian); }
internal double ReadDouble(long translatedRowIndex, long translatedColumnIndex) { var columnMetadata = Metadata.Columns[translatedColumnIndex]; var dataOffset = columnMetadata.DataOffset; var valueOffset = dataOffset + translatedRowIndex * sizeof(double); return(View.ReadDouble(valueOffset)); }
public Star this[long i] { get { if (i > capacity) { throw new ArgumentOutOfRangeException(); } var pos = i * StarSizeInBytes; var star = new Star { X = view.ReadDouble(pos) }; pos += sizeof(double); star.Y = view.ReadDouble(pos); pos += sizeof(double); star.Z = view.ReadDouble(pos); pos += sizeof(double); star.AbsoluteMagnitude = view.ReadSingle(pos); pos += sizeof(float); star.Temperature = view.ReadSingle(pos); return(star); } set { if (i > capacity) { throw new ArgumentOutOfRangeException(); } var pos = i * StarSizeInBytes; view.Write(pos, value.X); pos += sizeof(double); view.Write(pos, value.Y); pos += sizeof(double); view.Write(pos, value.Z); pos += sizeof(double); view.Write(pos, value.AbsoluteMagnitude); pos += sizeof(float); view.Write(pos, value.Temperature); } }
public static DateTime[] ReadClipIndicators(MemoryMappedViewAccessor accessor) { var clipTimeLeftMillis = accessor.ReadDouble(4); var clipTimeRightMillis = accessor.ReadDouble(12); if (double.IsNaN(clipTimeLeftMillis) || double.IsInfinity(clipTimeLeftMillis)) { clipTimeLeftMillis = 0; } if (double.IsNaN(clipTimeRightMillis) || double.IsInfinity(clipTimeRightMillis)) { clipTimeRightMillis = 0; } var clipTimeLeft = new DateTime(1970, 1, 1).AddMilliseconds(clipTimeLeftMillis); var clipTimeRight = new DateTime(1970, 1, 1).AddMilliseconds(clipTimeRightMillis); return(new[] { clipTimeLeft, clipTimeRight }); }
/// <summary> /// /// </summary> /// <returns></returns> public double ReadDouble(long inPosition) { try { return(_sharedMemoryAccesor.ReadDouble(inPosition)); } catch { return(0); } }
public double ReadDouble() { double ret = 0; if (ready) { accessorMutex.WaitOne(); ret = mmvAccessor.ReadDouble(0); accessorMutex.ReleaseMutex(); } return(ret); }
public double ReadDouble() { long position = _position + _origin; if (position + 8 > _length) { throw new IOException(SR.BlobReadOutOfBound); } var value = _accessor.ReadDouble(position); _position += 8; return(value); }
public double GetDouble() { const long size = 8; if (_position + size > _size) { _logger.Error($"Trying to read {size} bytes at {_position:X} with just {_size - _position} bytes left"); throw new OverflowException(); } var value = _va.ReadDouble(_offset + _position); _position += size; return(value); }
public double GetParameter(ParameterTypes ParameterType, int SubType) { if (m_MemoryMappedFile == null) { OpenMMF(); } try { return(m_MemoryMappedViewAccessor.ReadDouble((((int)ParameterType * 10) + SubType) * sizeof(double))); } catch (Exception e) { return(-99999.99999); } }
static Telemetry ReadAllValues(MemoryMappedViewAccessor accessor, int buffOffset, VarHeader[] varHeaders) { var result = new Telemetry(); var maps = new Dictionary <VarType, Func <int, object> >() { { VarType.irInt, (offset) => accessor.ReadInt32(offset) }, { VarType.irBitField, (offset) => accessor.ReadInt32(offset) }, { VarType.irDouble, (offset) => accessor.ReadDouble(offset) }, { VarType.irBool, (offset) => accessor.ReadBoolean(offset) }, { VarType.irFloat, (offset) => accessor.ReadSingle(offset) } }; var arryMaps = new Dictionary <VarType, Func <int, int, object> >() { { VarType.irInt, (size, offset) => GetArrayData <int>(accessor, size, offset) }, { VarType.irBitField, (size, offset) => GetArrayData <int>(accessor, size, offset) }, { VarType.irDouble, (size, offset) => GetArrayData <double>(accessor, size, offset) }, { VarType.irFloat, (size, offset) => GetArrayData <float>(accessor, size, offset) }, { VarType.irBool, (size, offset) => GetArrayData <bool>(accessor, size, offset) } }; for (var i = 0; i < varHeaders.Length; i++) { var varHeader = varHeaders[i]; var offset = buffOffset + varHeader.offset; if (varHeader.type == VarType.irChar) { throw new NotSupportedException(); } object value; if (varHeader.count != 1) { value = arryMaps[varHeader.type](varHeader.count, offset); } else { value = maps[varHeader.type](offset); } result.Add(varHeader.name, value); } return(result); }
public double?GetParameter(int ParameterType, int SubType) { if (m_MemoryMappedFile == null) { OpenMMF(); } try { return(m_MemoryMappedViewAccessor.ReadDouble((((int)ParameterType * 10) + SubType) * sizeof(double))); } catch (Exception e) { Console.Write(e.ToString()); return(null); } }
// Update is called once per frame void Update() { double num = accessor.ReadDouble(0); reciveMesSize = accessor.ReadArray <byte>(sizeof(double), data, 0, size); sharedMsg = System.Text.Encoding.UTF8.GetString(data); int imageSize = accessor_image.ReadArray <byte>(0, data_image, 0, 640 * 480 * 3); tex.LoadRawTextureData(data_image); tex.Apply(); RImg.texture = tex; text.text = sharedMsg; }
private double ReadDouble(ref int offset) { double result = _memoryMappedViewAccessor.ReadDouble(offset); offset += DoubleOffset; return result; }
public double ReadDouble(int offset) { return(_f.ReadDouble(offset)); }
public void updateData() { if (initialized) { Int64 pos = 0; state = shmem.ReadInt32(pos); pos += sizeof(Int32); carid = shmem.ReadInt32(pos); pos += sizeof(Int32); gear = shmem.ReadInt32(pos); pos += sizeof(Int32); lap = shmem.ReadInt32(pos); pos += sizeof(Int32); totallaps = shmem.ReadInt32(pos); pos += sizeof(Int32); position = shmem.ReadInt32(pos); pos += sizeof(Int32); pitlimiter = shmem.ReadInt32(pos); pos += sizeof(Int32); sessiontype = shmem.ReadInt32(pos); pos += sizeof(Int32); carinfront = shmem.ReadInt32(pos); pos += sizeof(Int32); timestamp = shmem.ReadDouble(pos); pos += sizeof(Double); speed = shmem.ReadDouble(pos); pos += sizeof(Double); rpm = shmem.ReadDouble(pos); pos += sizeof(Double); fuel = shmem.ReadDouble(pos); pos += sizeof(Double); prevlap = shmem.ReadDouble(pos); pos += sizeof(Double); trackLength = shmem.ReadDouble(pos); pos += sizeof(Double); maxrpm = shmem.ReadDouble(pos); pos += sizeof(Double); shmem.ReadArray <Double>(pos, driverTrkPos, 0, maxcars); pos += maxcars * sizeof(Double); Byte[] buf = new Byte[64]; shmem.ReadArray <Byte>(pos, buf, 0, 64); pos += 64 * sizeof(Byte); buf = Encoding.Convert(Encoding.GetEncoding("iso-8859-1"), Encoding.UTF8, buf); carname = Encoding.UTF8.GetString(buf, 0, 64); carname = carname.Substring(0, carname.IndexOf('\0')); shmem.ReadArray <Byte>(pos, buf, 0, 64); pos += 64 * sizeof(Byte); buf = Encoding.Convert(Encoding.GetEncoding("iso-8859-1"), Encoding.UTF8, buf); trackname = Encoding.UTF8.GetString(buf, 0, 64); trackname = trackname.Substring(0, trackname.IndexOf('\0')); // process if (needReset && trackLength > 0) { reset(); LoadBestLap(); needReset = false; } if (prevstate != state) { if (state == 2) // entering driving mode { LoadBestLap(); } else if (prevstate == 2) // exiting driving mode { SaveBestLap(); } prevstate = state; } timedelta.Update(timestamp, driverTrkPos); if (driverTrkPos[carid] < 0.1 && lastTickTrackPos > 0.9) { Double distance = (1 - lastTickTrackPos) + driverTrkPos[carid]; Double time = timestamp - lastTickTime; Double tickCorrection = (1 - lastTickTrackPos) / distance; // save lap time if (lapTimeValid) { fuelcons[fuelconsPtr % fuelcons.Length] = fuel; // update fuel consumption after one full lap if (fuelconsPtr > 0) { if (fuelconsPtr >= fuelcons.Length) { Double[] consrate = new Double[fuelcons.Length - 1]; Int32 j = 0; for (int i = fuelconsPtr; i < fuelconsPtr + consrate.Length; i++) { consrate[j++] = fuelcons[(i + 1) % fuelcons.Length] - fuelcons[(i + 2) % fuelcons.Length]; } fuelneed = (Int32)(fuelcons[fuelconsPtr % fuelcons.Length] - ((totallaps - lap) * consrate.Average())); fuelconsumption = consrate.Average(); } else if (fuelconsPtr > 0) { fuelneed = (Int32)(fuelcons[fuelconsPtr % fuelcons.Length] - ((totallaps - lap) * fuelcons[(fuelconsPtr - 1) % fuelcons.Length])); fuelconsumption = fuelcons[(fuelconsPtr - 1) % fuelcons.Length] - fuelcons[fuelconsPtr % fuelcons.Length]; } } fuelconsPtr++; } // start new lap lapStartTime = timestamp - (1 - tickCorrection) * time; lapTimeValid = true; // reset fuel consumption when in pits if (driverTrkPos[carid] < 0) { fuelcons = new Double[fuelconslaps]; fuelconsPtr = 0; } } else if (Math.Abs(driverTrkPos[carid] - lastTickTrackPos) > 0.1) { // invalidate lap time if jumping too much lapTimeValid = false; } lastTickTrackPos = driverTrkPos[carid]; // save for next tick lastTickTime = timestamp; if (sessiontype >= 10) // if (race) { delta = timedelta.GetDelta(carid, carinfront); } else { delta = timedelta.GetBestLapDelta(driverTrkPos[carid] % 1); } } }
public object GetData(string name) { if (IsInitialized && Header != null) { CVarHeader header = null; if (VarHeaders.TryGetValue(name, out header)) { int varOffset = header.Offset; int count = header.Count; if (header.Type == CVarHeader.VarType.irChar) { byte[] data = new byte[count]; FileMapView.ReadArray <byte>(Header.Buffer + varOffset, data, 0, count); return(System.Text.Encoding.Default.GetString(data).TrimEnd(new char[] { '\0' })); } else if (header.Type == CVarHeader.VarType.irBool) { if (count > 1) { bool[] data = new bool[count]; FileMapView.ReadArray <bool>(Header.Buffer + varOffset, data, 0, count); return(data); } else { return(FileMapView.ReadBoolean(Header.Buffer + varOffset)); } } else if (header.Type == CVarHeader.VarType.irInt || header.Type == CVarHeader.VarType.irBitField) { if (count > 1) { int[] data = new int[count]; FileMapView.ReadArray <int>(Header.Buffer + varOffset, data, 0, count); return(data); } else { return(FileMapView.ReadInt32(Header.Buffer + varOffset)); } } else if (header.Type == CVarHeader.VarType.irFloat) { if (count > 1) { float[] data = new float[count]; FileMapView.ReadArray <float>(Header.Buffer + varOffset, data, 0, count); return(data); } else { return(FileMapView.ReadSingle(Header.Buffer + varOffset)); } } else if (header.Type == CVarHeader.VarType.irDouble) { if (count > 1) { double[] data = new double[count]; FileMapView.ReadArray <double>(Header.Buffer + varOffset, data, 0, count); return(data); } else { return(FileMapView.ReadDouble(Header.Buffer + varOffset)); } } } } return(null); }
public object GetData(string name) { if (!IsInitialized || Header == null) { return(null); } if (!VarHeaders.ContainsKey(name)) { return(null); } var varOffset = VarHeaders[name].Offset; var count = VarHeaders[name].Count; switch (VarHeaders[name].Type) { case CVarHeader.VarType.IrChar: var bytes = new byte[count]; _fileMapView.ReadArray(Header.Buffer + varOffset, bytes, 0, count); return(Encoding.Default.GetString(bytes).TrimEnd('\0')); case CVarHeader.VarType.IrBool: if (count > 1) { var data = new bool[count]; _fileMapView.ReadArray(Header.Buffer + varOffset, data, 0, count); return(data); } return(_fileMapView.ReadBoolean(Header.Buffer + varOffset)); case CVarHeader.VarType.IrInt: case CVarHeader.VarType.IrBitField: if (count > 1) { var data = new int[count]; _fileMapView.ReadArray(Header.Buffer + varOffset, data, 0, count); return(data); } return(_fileMapView.ReadInt32(Header.Buffer + varOffset)); case CVarHeader.VarType.IrFloat: if (count > 1) { var data = new float[count]; _fileMapView.ReadArray(Header.Buffer + varOffset, data, 0, count); return(data); } return(_fileMapView.ReadSingle(Header.Buffer + varOffset)); case CVarHeader.VarType.IrDouble: if (count > 1) { var data = new double[count]; _fileMapView.ReadArray(Header.Buffer + varOffset, data, 0, count); return(data); } return(_fileMapView.ReadDouble(Header.Buffer + varOffset)); default: return(null); } }
public object GetData(string name) { if (IsInitialized && Header != null) { if (VarHeaders.ContainsKey(name)) { int varOffset = VarHeaders[name].Offset; int count = VarHeaders[name].Count; if (VarHeaders[name].Type == CVarHeader.VarType.irChar) { byte[] data = new byte[count]; FileMapView.ReadArray(Header.Buffer + varOffset, data, 0, count); return(encoding.GetString(data).TrimEnd(new char[] { '\0' })); } else if (VarHeaders[name].Type == CVarHeader.VarType.irBool) { if (count > 1) { bool[] data = new bool[count]; FileMapView.ReadArray(Header.Buffer + varOffset, data, 0, count); return(data); } else { return(FileMapView.ReadBoolean(Header.Buffer + varOffset)); } } else if (VarHeaders[name].Type == CVarHeader.VarType.irInt || VarHeaders[name].Type == CVarHeader.VarType.irBitField) { if (count > 1) { int[] data = new int[count]; FileMapView.ReadArray(Header.Buffer + varOffset, data, 0, count); return(data); } else { return(FileMapView.ReadInt32(Header.Buffer + varOffset)); } } else if (VarHeaders[name].Type == CVarHeader.VarType.irFloat) { if (count > 1) { float[] data = new float[count]; FileMapView.ReadArray(Header.Buffer + varOffset, data, 0, count); return(data); } else { return(FileMapView.ReadSingle(Header.Buffer + varOffset)); } } else if (VarHeaders[name].Type == CVarHeader.VarType.irDouble) { if (count > 1) { double[] data = new double[count]; FileMapView.ReadArray(Header.Buffer + varOffset, data, 0, count); return(data); } else { return(FileMapView.ReadDouble(Header.Buffer + varOffset)); } } } } return(null); }
/// <summary>Performs many reads and writes of various data types against the accessor.</summary> private static void AssertWritesReads(MemoryMappedViewAccessor acc) { // Successful reads and writes at the beginning for each data type AssertWriteRead <bool>(false, 0, (pos, value) => acc.Write(pos, value), pos => acc.ReadBoolean(pos)); AssertWriteRead <bool>(true, 0, (pos, value) => acc.Write(pos, value), pos => acc.ReadBoolean(pos)); AssertWriteRead <byte>(42, 0, (pos, value) => acc.Write(pos, value), pos => acc.ReadByte(pos)); AssertWriteRead <char>('c', 0, (pos, value) => acc.Write(pos, value), pos => acc.ReadChar(pos)); AssertWriteRead <decimal>(9, 0, (pos, value) => acc.Write(pos, value), pos => acc.ReadDecimal(pos)); AssertWriteRead <double>(10, 0, (pos, value) => acc.Write(pos, value), pos => acc.ReadDouble(pos)); AssertWriteRead <short>(11, 0, (pos, value) => acc.Write(pos, value), pos => acc.ReadInt16(pos)); AssertWriteRead <int>(12, 0, (pos, value) => acc.Write(pos, value), pos => acc.ReadInt32(pos)); AssertWriteRead <long>(13, 0, (pos, value) => acc.Write(pos, value), pos => acc.ReadInt64(pos)); AssertWriteRead <sbyte>(14, 0, (pos, value) => acc.Write(pos, value), pos => acc.ReadSByte(pos)); AssertWriteRead <float>(15, 0, (pos, value) => acc.Write(pos, value), pos => acc.ReadSingle(pos)); AssertWriteRead <ushort>(16, 0, (pos, value) => acc.Write(pos, value), pos => acc.ReadUInt16(pos)); AssertWriteRead <uint>(17, 0, (pos, value) => acc.Write(pos, value), pos => acc.ReadUInt32(pos)); AssertWriteRead <ulong>(17, 0, (pos, value) => acc.Write(pos, value), pos => acc.ReadUInt64(pos)); // Successful reads and writes at the end for each data type long end = acc.Capacity; AssertWriteRead <bool>(false, end - sizeof(bool), (pos, value) => acc.Write(pos, value), pos => acc.ReadBoolean(pos)); AssertWriteRead <bool>(true, end - sizeof(bool), (pos, value) => acc.Write(pos, value), pos => acc.ReadBoolean(pos)); AssertWriteRead <byte>(42, end - sizeof(byte), (pos, value) => acc.Write(pos, value), pos => acc.ReadByte(pos)); AssertWriteRead <char>('c', end - sizeof(char), (pos, value) => acc.Write(pos, value), pos => acc.ReadChar(pos)); AssertWriteRead <decimal>(9, end - sizeof(decimal), (pos, value) => acc.Write(pos, value), pos => acc.ReadDecimal(pos)); AssertWriteRead <double>(10, end - sizeof(double), (pos, value) => acc.Write(pos, value), pos => acc.ReadDouble(pos)); AssertWriteRead <short>(11, end - sizeof(short), (pos, value) => acc.Write(pos, value), pos => acc.ReadInt16(pos)); AssertWriteRead <int>(12, end - sizeof(int), (pos, value) => acc.Write(pos, value), pos => acc.ReadInt32(pos)); AssertWriteRead <long>(13, end - sizeof(long), (pos, value) => acc.Write(pos, value), pos => acc.ReadInt64(pos)); AssertWriteRead <sbyte>(14, end - sizeof(sbyte), (pos, value) => acc.Write(pos, value), pos => acc.ReadSByte(pos)); AssertWriteRead <float>(15, end - sizeof(float), (pos, value) => acc.Write(pos, value), pos => acc.ReadSingle(pos)); AssertWriteRead <ushort>(16, end - sizeof(ushort), (pos, value) => acc.Write(pos, value), pos => acc.ReadUInt16(pos)); AssertWriteRead <uint>(17, end - sizeof(uint), (pos, value) => acc.Write(pos, value), pos => acc.ReadUInt32(pos)); AssertWriteRead <ulong>(17, end - sizeof(ulong), (pos, value) => acc.Write(pos, value), pos => acc.ReadUInt64(pos)); // Failed reads and writes just at the border of the end. This triggers different exception types // for some types than when we're completely beyond the end. long beyondEnd = acc.Capacity + 1; AssertExtensions.Throws <ArgumentOutOfRangeException>("position", () => acc.ReadBoolean(beyondEnd - sizeof(bool))); AssertExtensions.Throws <ArgumentOutOfRangeException>("position", () => acc.ReadByte(beyondEnd - sizeof(byte))); AssertExtensions.Throws <ArgumentOutOfRangeException>("position", () => acc.ReadSByte(beyondEnd - sizeof(sbyte))); AssertExtensions.Throws <ArgumentException>("position", () => acc.ReadChar(beyondEnd - sizeof(char))); AssertExtensions.Throws <ArgumentException>("position", () => acc.ReadDecimal(beyondEnd - sizeof(decimal))); AssertExtensions.Throws <ArgumentException>("position", () => acc.ReadDouble(beyondEnd - sizeof(double))); AssertExtensions.Throws <ArgumentException>("position", () => acc.ReadInt16(beyondEnd - sizeof(short))); AssertExtensions.Throws <ArgumentException>("position", () => acc.ReadInt32(beyondEnd - sizeof(int))); AssertExtensions.Throws <ArgumentException>("position", () => acc.ReadInt64(beyondEnd - sizeof(long))); AssertExtensions.Throws <ArgumentException>("position", () => acc.ReadSingle(beyondEnd - sizeof(float))); AssertExtensions.Throws <ArgumentException>("position", () => acc.ReadUInt16(beyondEnd - sizeof(ushort))); AssertExtensions.Throws <ArgumentException>("position", () => acc.ReadUInt32(beyondEnd - sizeof(uint))); AssertExtensions.Throws <ArgumentException>("position", () => acc.ReadUInt64(beyondEnd - sizeof(ulong))); AssertExtensions.Throws <ArgumentOutOfRangeException>("position", () => acc.Write(beyondEnd - sizeof(bool), false)); AssertExtensions.Throws <ArgumentOutOfRangeException>("position", () => acc.Write(beyondEnd - sizeof(byte), (byte)0)); AssertExtensions.Throws <ArgumentOutOfRangeException>("position", () => acc.Write(beyondEnd - sizeof(sbyte), (sbyte)0)); AssertExtensions.Throws <ArgumentException>("position", () => acc.Write(beyondEnd - sizeof(char), 'c')); AssertExtensions.Throws <ArgumentException>("position", () => acc.Write(beyondEnd - sizeof(decimal), (decimal)0)); AssertExtensions.Throws <ArgumentException>("position", () => acc.Write(beyondEnd - sizeof(double), (double)0)); AssertExtensions.Throws <ArgumentException>("position", () => acc.Write(beyondEnd - sizeof(short), (short)0)); AssertExtensions.Throws <ArgumentException>("position", () => acc.Write(beyondEnd - sizeof(int), (int)0)); AssertExtensions.Throws <ArgumentException>("position", () => acc.Write(beyondEnd - sizeof(long), (long)0)); AssertExtensions.Throws <ArgumentException>("position", () => acc.Write(beyondEnd - sizeof(float), (float)0)); AssertExtensions.Throws <ArgumentException>("position", () => acc.Write(beyondEnd - sizeof(ushort), (ushort)0)); AssertExtensions.Throws <ArgumentException>("position", () => acc.Write(beyondEnd - sizeof(uint), (uint)0)); AssertExtensions.Throws <ArgumentException>("position", () => acc.Write(beyondEnd - sizeof(ulong), (ulong)0)); // Failed reads and writes well past the end beyondEnd = acc.Capacity + 20; AssertExtensions.Throws <ArgumentOutOfRangeException>("position", () => acc.ReadBoolean(beyondEnd - sizeof(bool))); AssertExtensions.Throws <ArgumentOutOfRangeException>("position", () => acc.ReadByte(beyondEnd - sizeof(byte))); AssertExtensions.Throws <ArgumentOutOfRangeException>("position", () => acc.ReadSByte(beyondEnd - sizeof(sbyte))); AssertExtensions.Throws <ArgumentOutOfRangeException>("position", () => acc.ReadChar(beyondEnd - sizeof(char))); AssertExtensions.Throws <ArgumentOutOfRangeException>("position", () => acc.ReadDecimal(beyondEnd - sizeof(decimal))); AssertExtensions.Throws <ArgumentOutOfRangeException>("position", () => acc.ReadDouble(beyondEnd - sizeof(double))); AssertExtensions.Throws <ArgumentOutOfRangeException>("position", () => acc.ReadInt16(beyondEnd - sizeof(short))); AssertExtensions.Throws <ArgumentOutOfRangeException>("position", () => acc.ReadInt32(beyondEnd - sizeof(int))); AssertExtensions.Throws <ArgumentOutOfRangeException>("position", () => acc.ReadInt64(beyondEnd - sizeof(long))); AssertExtensions.Throws <ArgumentOutOfRangeException>("position", () => acc.ReadSingle(beyondEnd - sizeof(float))); AssertExtensions.Throws <ArgumentOutOfRangeException>("position", () => acc.ReadUInt16(beyondEnd - sizeof(ushort))); AssertExtensions.Throws <ArgumentOutOfRangeException>("position", () => acc.ReadUInt32(beyondEnd - sizeof(uint))); AssertExtensions.Throws <ArgumentOutOfRangeException>("position", () => acc.ReadUInt64(beyondEnd - sizeof(ulong))); AssertExtensions.Throws <ArgumentOutOfRangeException>("position", () => acc.Write(beyondEnd - sizeof(bool), false)); AssertExtensions.Throws <ArgumentOutOfRangeException>("position", () => acc.Write(beyondEnd - sizeof(byte), (byte)0)); AssertExtensions.Throws <ArgumentOutOfRangeException>("position", () => acc.Write(beyondEnd - sizeof(sbyte), (sbyte)0)); AssertExtensions.Throws <ArgumentOutOfRangeException>("position", () => acc.Write(beyondEnd - sizeof(char), 'c')); AssertExtensions.Throws <ArgumentOutOfRangeException>("position", () => acc.Write(beyondEnd - sizeof(decimal), (decimal)0)); AssertExtensions.Throws <ArgumentOutOfRangeException>("position", () => acc.Write(beyondEnd - sizeof(double), (double)0)); AssertExtensions.Throws <ArgumentOutOfRangeException>("position", () => acc.Write(beyondEnd - sizeof(short), (short)0)); AssertExtensions.Throws <ArgumentOutOfRangeException>("position", () => acc.Write(beyondEnd - sizeof(int), (int)0)); AssertExtensions.Throws <ArgumentOutOfRangeException>("position", () => acc.Write(beyondEnd - sizeof(long), (long)0)); AssertExtensions.Throws <ArgumentOutOfRangeException>("position", () => acc.Write(beyondEnd - sizeof(float), (float)0)); AssertExtensions.Throws <ArgumentOutOfRangeException>("position", () => acc.Write(beyondEnd - sizeof(ushort), (ushort)0)); AssertExtensions.Throws <ArgumentOutOfRangeException>("position", () => acc.Write(beyondEnd - sizeof(uint), (uint)0)); AssertExtensions.Throws <ArgumentOutOfRangeException>("position", () => acc.Write(beyondEnd - sizeof(ulong), (ulong)0)); }
public object GetData(string name) { if (!IsStarted || Header == null) { return(null); } if (!VarHeaders.TryGetValue(name, out var requestedHeader)) { return(null); } int varOffset = requestedHeader.Offset; int count = requestedHeader.Count; switch (requestedHeader.Type) { case VarType.irChar: { byte[] data = new byte[count]; FileMapView.ReadArray(Header.Offset + varOffset, data, 0, count); return(_encoding.GetString(data).TrimEnd(trimChars)); } case VarType.irBool: { if (count > 1) { bool[] data = new bool[count]; FileMapView.ReadArray(Header.Offset + varOffset, data, 0, count); return(data); } else { return(FileMapView.ReadBoolean(Header.Offset + varOffset)); } } case VarType.irInt: case VarType.irBitField: { if (count > 1) { int[] data = new int[count]; FileMapView.ReadArray(Header.Offset + varOffset, data, 0, count); return(data); } else { return(FileMapView.ReadInt32(Header.Offset + varOffset)); } } case VarType.irFloat: { if (count > 1) { float[] data = new float[count]; FileMapView.ReadArray(Header.Offset + varOffset, data, 0, count); return(data); } else { return(FileMapView.ReadSingle(Header.Offset + varOffset)); } } case VarType.irDouble: { if (count > 1) { double[] data = new double[count]; FileMapView.ReadArray(Header.Offset + varOffset, data, 0, count); return(data); } else { return(FileMapView.ReadDouble(Header.Offset + varOffset)); } } default: return(null); } }