//assuming this method is not called during initialization as it raises Data_Bank_Change event public void AddEntry(FutureEntry fe) { if (ForceUpdate || isNewerEntry(fe)) { databank[fe.id] = fe; Data_Bank_Change(this, new EventArgs()); databank_modified = true; } }
public void On_Found_Future_Entry(object sender, ScannerEventArg arg) { //handles event FutureEntry fe = arg.Fe; AddEntry(fe); FE_Being_Processed(this, new ScannerEventArg(fe)); }
private bool isNewerEntry(FutureEntry fe) { if (databank.ContainsKey(fe.id)) { if (databank[fe.id].publication_date < fe.publication_date) { return(true); } else { return(false); } } else { return(true); } }
public EntryManager() { ForceUpdate = false; databank = new Dictionary <int, FutureEntry>(); if (File.Exists(data_file_dir) == true) { //read from file and populate databank StreamReader datafile = new StreamReader(data_file_dir); string line; while ((line = datafile.ReadLine()) != null) { string[] segs = line.Split(delimeter);//delimeter is private static member of this class try { int id = int.Parse(segs[0]); DateTime f_date = new DateTime(int.Parse(segs[1]), int.Parse(segs[2]), int.Parse(segs[3])); DateTime p_date = new DateTime(int.Parse(segs[4]), int.Parse(segs[5]), int.Parse(segs[6])); string title = segs[7]; if (segs.Length > 8) { for (int i = 8; i < segs.Length; i++) { title += ","; title += segs[i]; } } databank[id] = new FutureEntry(f_date, p_date, id, title); } catch { continue; } } datafile.Close(); } else { File.Create(data_file_dir); } databank_modified = false; Data_Bank_Change += On_Data_Bank_Change; }
public IEnumerable <int> KeyIndices() { var future = Enumerable.Range(0, FutureLength).Select(i => new FutureEntry(i, Source.Get(i))).ToArray(); for (int index = 0;; index++) { int futureIndex = index % FutureLength; Debug.Assert(future[futureIndex].Index == index); var current = future[futureIndex].Data; future[futureIndex] = new FutureEntry(index + FutureLength, Source.Get(index + FutureLength)); var c = TripletFinder.Find(current); if (!c.HasValue) { continue; } string confirm = string.Join("", Enumerable.Repeat(c.Value, 5)); if (future.Any(fe => fe.Data.Contains(confirm))) { yield return(index); } } }
private void update_status_bar(FutureEntry arg) { RecentChangeLabel.Text = arg.ToString(); }