Exemplo n.º 1
0
        /// <summary>
        /// Deserializes the path infos from the source stream.
        /// </summary>
        /// <param name="source">The source stream.</param>
        /// <returns>The path infos.</returns>
        public static IEnumerable <PathInfo> DeserializeFromStream(this Stream source)
        {
            var format = (PathInfoFormat)source.ReadByte();
            IPathsSerializer serializer = format == PathInfoFormat.Compact ? new CompactPathsSerializer() as IPathsSerializer : new NormalPathsSerializer();

            return(serializer.Deserialize(source));
        }
Exemplo n.º 2
0
        /// <summary>
        /// Serializes the path infos to the target stream.
        /// </summary>
        /// <param name="pathInfos">The path infos.</param>
        /// <param name="target">The target stream.</param>
        /// <param name="format">The format.</param>
        public static void SerializeToStream(this IEnumerable <PathInfo> pathInfos, Stream target, PathInfoFormat format = PathInfoFormat.Compact)
        {
            IPathsSerializer serializer = format == PathInfoFormat.Compact ? new CompactPathsSerializer() as IPathsSerializer : new NormalPathsSerializer();

            target.WriteByte((byte)format);
            serializer.Serialize(pathInfos, target);
        }