/// <summary> /// Reads the file header. /// </summary> /// <exception cref="System.IO.InvalidDataException">Stream content is in an invalid format.</exception> private void ReadHeader() { _baseStream.Seek(0, SeekOrigin.Begin); Byte[] headerBytes = new Byte[100]; _baseStream.Read(headerBytes, 0, headerBytes.Length); // perform checks for header if (EndianBitConverter.ToInt32(headerBytes, 0, ByteOrder.BigEndian) != 9994 || // identifier EndianBitConverter.ToInt32(headerBytes, 24, ByteOrder.BigEndian) != _baseStream.Length / 2 || // file length EndianBitConverter.ToInt32(headerBytes, 28, ByteOrder.LittleEndian) != 1000) // version { throw new InvalidDataException(MessageHeaderInvalid); } // shape type _shapeType = (ShapeType)EndianBitConverter.ToInt32(headerBytes, 32, ByteOrder.LittleEndian); // envelope Double xMin = EndianBitConverter.ToDouble(headerBytes, 36); Double yMin = EndianBitConverter.ToDouble(headerBytes, 44); Double xMax = EndianBitConverter.ToDouble(headerBytes, 52); Double yMax = EndianBitConverter.ToDouble(headerBytes, 60); Double zMin = EndianBitConverter.ToDouble(headerBytes, 68); Double zMax = EndianBitConverter.ToDouble(headerBytes, 76); _envelope = new Envelope(xMin, xMax, yMin, yMax, zMin, zMax); // load metadata for shapes if (_fileSystem.Exists(MetadataFilePath)) { _metadataReader = new DBaseStreamReader(OpenPath(MetadataFilePath)); } }
/// <summary> /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. /// </summary> /// <param name="disposing">A value indicating whether disposing is performed on the object.</param> protected override void Dispose(Boolean disposing) { if (disposing) { if (_metadataReader != null) { _metadataReader.Dispose(); _metadataReader = null; } _shapeIndex = null; } base.Dispose(disposing); }