/// <summary> /// Deserializes the given stream into an index. /// </summary> /// <param name="stream"></param> /// <param name="lazy"></param> /// <returns></returns> public ISpatialIndexReadonly <T> Deserialize(Stream stream, bool lazy = true) { if (stream == null) { throw new ArgumentNullException("stream"); } if (this.CanDeSerialize(stream)) { // read/verify the current version header. this.ReadAndValidateHeader(stream); // wrap the stream. var spatialIndexSerializerStream = new SpatialIndexSerializerStream(stream); // do the actual version-specific deserialization. return(this.DoDeserialize(spatialIndexSerializerStream, lazy)); } throw new ArgumentOutOfRangeException("stream", "Cannot deserialize the given stream, version unsupported or content unrecognized!"); }
/// <summary> /// Serializes the given graph and tags index to the given stream. /// </summary> /// <param name="stream"></param> /// <param name="index"></param> public void Serialize(Stream stream, RTreeMemoryIndex <T> index) { if (stream == null) { throw new ArgumentNullException("stream"); } if (index == null) { throw new ArgumentNullException("index"); } // write the header. this.WriteVersionHeader(stream); // wrap the stream. var spatialIndexSerializerStream = new SpatialIndexSerializerStream(stream); // do the version-specific serialization. this.DoSerialize(spatialIndexSerializerStream, index); }
protected abstract ISpatialIndexReadonly <T> DoDeserialize(SpatialIndexSerializerStream stream, bool lazy);
protected abstract void DoSerialize(SpatialIndexSerializerStream stream, RTreeMemoryIndex <T> index);