コード例 #1
0
        /// <summary>
        /// Initializes the cache from file.
        /// </summary>
        public static void InitializeFromFile()
        {
            // Quit if the client has been shut down
            if (EveMonClient.Closed)
            {
                return;
            }

            string file = LocalXmlCache.GetFileInfo(Filename).FullName;

            if (!File.Exists(file) || s_cacheList.Any())
            {
                return;
            }

            // Deserialize the file
            SerializableStationList cache = Util.DeserializeXmlFromFile <SerializableStationList>(file);

            // Reset the cache if anything went wrong
            if (cache == null || cache.Stations.Any(x => x.StationID == 0) ||
                cache.Stations.Any(x => x.StationName.Length == 0))
            {
                EveMonClient.Trace("Station and citadel deserialization failed; deleting file.");
                FileHelper.DeleteFile(file);
                return;
            }

            // Add the data to the cache
            Import(cache.Stations);
        }
コード例 #2
0
        /// <summary>
        /// Exports the cache list to a serializable object.
        /// </summary>
        /// <returns></returns>
        private static SerializableStationList Export()
        {
            var serial = new SerializableStationList();

            lock (s_cacheList)
            {
                serial.Stations.AddRange(s_cacheList.Values);
            }

            return(serial);
        }
コード例 #3
0
ファイル: EveIDToStation.cs プロジェクト: Qruze/evemon
        /// <summary>
        /// Exports the cache list to a serializable object.
        /// </summary>
        /// <returns></returns>
        private static SerializableStationList Export()
        {
            var serial = new SerializableStationList();

            lock (s_cacheList)
            {
                foreach (var station in s_cacheList.Values)
                {
                    // Only add stations which have been successfully fetched
                    var result = station.Station;
                    if (result != null)
                    {
                        serial.Stations.Add(result);
                    }
                }
            }

            return(serial);
        }