Beispiel #1
0
        /// <summary>
        /// Gets or a loaded IMap or seamslessly loads it into memory.
        /// </summary>
        /// <param name="mapFilePath">full path to datafile</param>
        /// <returns></returns>
        public IMap GetMap(string mapFilePath, MapTypes type)
        {
            if (!File.Exists(mapFilePath))
            {
                return(new EmptyMapWithError("File does not exist!"));
            }
            lock (_object)
            {
                if (!_loadedMaps.ContainsKey(mapFilePath))
                {
                    switch (type)
                    {
                    case MapTypes.Grid:
                        var task = GridFactory.ReadGrid(mapFilePath);
                        _loadedMaps.TryAdd(mapFilePath, task.Result);
                        break;

                    default:
                        return(new EmptyMapWithError("Cannot find Map Type. Please enter a valid one."));
                    }
                }
            }
            return(_loadedMaps[mapFilePath]);
        }