/// <summary> /// Deserializes the given stream into a routable graph. /// </summary> /// <param name="stream"></param> /// <param name="lazy"></param> /// <returns></returns> public IBasicRouterDataSource<PreProcessedEdge> 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 routingSerializerStream = new RoutingSerializerStream(stream); // do the actual version-specific deserialization. return this.DoDeserialize(routingSerializerStream, lazy); } throw new ArgumentOutOfRangeException("stream", "Cannot deserialize the given stream, version unsupported or content unrecognized!"); }
/// <summary> /// Deserializes the given stream into a routable graph. /// </summary> /// <param name="stream"></param> /// <param name="lazy"></param> /// <returns></returns> protected abstract IBasicRouterDataSource<PreProcessedEdge> DoDeserialize(RoutingSerializerStream stream, bool lazy);
/// <summary> /// Serializes the given graph and tags index to the given stream. /// </summary> /// <param name="stream"></param> /// <param name="graph"></param> public void Serialize(Stream stream, DynamicGraphRouterDataSource<PreProcessedEdge> graph) { if (stream == null) throw new ArgumentNullException("stream"); if (graph == null) throw new ArgumentNullException("graph"); // write the header. this.WriteVersionHeader(stream); // wrap the stream. var routingSerializerStream = new RoutingSerializerStream(stream); // do the version-specific serialization. this.DoSerialize(routingSerializerStream, graph); }
/// <summary> /// Serializes the given graph and tags index to the given stream. /// </summary> /// <param name="stream"></param> /// <param name="graph"></param> protected abstract void DoSerialize(RoutingSerializerStream stream, DynamicGraphRouterDataSource<PreProcessedEdge> graph);