/// <summary> /// Initializes the cache of SWUM data from a file. Any existing SWUM data will be cleared before reading the file. /// </summary> /// <param name="path">The path to the SWUM cache file.</param> public void ReadSwumCache(string path) { using (var cacheFile = new StreamReader(path)) { lock (signaturesToSwum) { //clear any existing SWUMs signaturesToSwum.Clear(); //read each SWUM entry from the cache file string entry; while ((entry = cacheFile.ReadLine()) != null) { //the expected format is <signature>|<SwumDataRecord.ToString()> string[] fields = entry.Split(new[] { '|' }, 2); if (fields.Length != 2) { Debug.WriteLine(string.Format("Too few fields in SWUM cache entry: {0}", entry)); continue; } try { string sig = fields[0].Trim(); string data = fields[1].Trim(); signaturesToSwum[sig] = SwumDataRecord.Parse(data); } catch (FormatException fe) { Debug.WriteLine(string.Format("Improperly formatted SwumDataRecord in Swum cache entry: {0}", entry)); Debug.WriteLine(fe.Message); } } } } }