Ejemplo n.º 1
0
        /// <summary>
        /// Loads the specified stream as a map.
        /// </summary>
        /// <param name="mapStream">The stream to load data from</param>
        /// <param name="loadCallback">An optional callback that will be invoked after each map is created</param>
        public TMap Load <TMap>(Stream mapStream, MapLoadCallback loadCallback = null) where TMap : IMap, new()
        {
            var reader = this.GetAggregateStream(mapStream);

            var map = this.CreateMap <TMap>(reader);

            foreach (var id in this.config.AncillaryMaps.Keys)
            {
                var anc = this.CreateMap <TMap>(reader, id);
                map.UseAncillaryMap(id, anc);
                loadCallback?.Invoke(anc, reader.GetStream(id));
            }

            loadCallback?.Invoke(map, reader.Map);

            return(map);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Loads the specified file as a map.
        /// </summary>
        /// <param name="mapName">The filename to load map data from. Will be combined with the current config's MapRoot</param>
        /// <param name="streamTransform">A delegate to tranform the map streams into a format that can be read. Typical use case is if the maps on disk are compressed.</param>
        /// <param name="loadCallback">An optional callback that will be invoked after each map is created</param>
        public TMap Load <TMap>(string mapName, MapStreamTransform streamTransform, MapLoadCallback loadCallback = null) where TMap : IMap, new()
        {
            var fs = new ReadOnlyFileStream(Path.Combine(this.config.MapRoot, mapName));

            return(this.Load <TMap>(fs, streamTransform, loadCallback));
        }