public override bool Load(string versionReuired) { try { string str; TrainsCacheStorage storage = new TrainsCacheStorage(); if (storage.Load(out str, out this.LastError)) { TrainsCache cache = DCSerializer.DeserializeWithDCS(typeof(TrainsCache), str) as TrainsCache; base.CacheTime = cache.CacheTime; this.Trains = cache.Trains; base.Version = cache.Version; if (!cache.IsValid(versionReuired, out this.LastError)) { return(false); } return(true); } } catch (Exception exception) { base.LastError = exception.Message; } return(false); }
public override bool Load(string versionReuired) { try { string str; TrainsCacheStorage storage = new TrainsCacheStorage(); if (storage.Load(out str, out this.LastError)) { TrainsCache cache = DCSerializer.DeserializeWithDCS(typeof(TrainsCache), str) as TrainsCache; base.CacheTime = cache.CacheTime; this.Trains = cache.Trains; base.Version = cache.Version; if (!cache.IsValid(versionReuired, out this.LastError)) { return false; } return true; } } catch (Exception exception) { base.LastError = exception.Message; } return false; }
private void buttonClearCache_Click(object sender, RoutedEventArgs e) { bool flag = true; string str = ""; TrainsCacheStorage storage = new TrainsCacheStorage(); if (!storage.Clear()) { flag = false; str = str + string.Format("\n\r {0}", storage.LastError); } TrainGraphCacheStorage storage2 = new TrainGraphCacheStorage(); if (!storage2.Clear()) { flag = false; str = str + string.Format("\n\r {0}", storage2.LastError); } LayoutCacheStorage storage3 = new LayoutCacheStorage(); if (!storage3.Clear()) { flag = false; str = str + string.Format("\n\r {0}", storage3.LastError); } if (flag) { MessageBox.Show("Cache removed successfully"); } else { MessageBox.Show("Cache removing failed..." + str); } }
public override bool Save() { TrainsCacheStorage storage = new TrainsCacheStorage(); string data = DCSerializer.SerializeWithDCS(this); storage.Clear(); bool flag = storage.Save(data, out this.LastError); base.LastError = base.LastError + string.Format(" Len={0}", data.Length); return flag; }
public override bool Save() { TrainsCacheStorage storage = new TrainsCacheStorage(); string data = DCSerializer.SerializeWithDCS(this); storage.Clear(); bool flag = storage.Save(data, out this.LastError); base.LastError = base.LastError + string.Format(" Len={0}", data.Length); return(flag); }