void test2() { myDb db = new myDb(); List <string> keys = new List <string> { @"c:\tmp\abc.txt", @"c:\tmp\123.txt" }; db.load(); chapterInfo c1 = new chapterInfo() { path = @"c:\tmp\123.txt", }; chapterInfo c2 = new chapterInfo() { path = @"c:\tmp\abc.txt", }; chapterInfo c3 = new chapterInfo() { path = @"c:\tmp\efd.txt", }; db.getMarked(c3); db.saveMarked(c3); db.getMarked(c1); db.getMarked(c2); c2.markedIndexs = new List <int> { 1, 2, 4 }; c1.markedIndexs = new List <int> { 7, 8, 9, 10, 11 }; db.saveMarked(c1); db.saveMarked(c2); db.unload(); db.load(); db.getMarked(c2); c2.markedIndexs = new List <int> { 1, 2, 4, 5, 6, 7, 8, 9, 10, 11 }; db.saveMarked(c2); c2.markedIndexs = new List <int> { 1, 2, 4, 5, 6, 7, 8, 9, 10 }; db.saveMarked(c2); c1.markedIndexs = new List <int> { 1, 2, 4, 5, 6, 7, 8, 9, 10 }; db.saveMarked(c1); db.loadMarkeds(new List <string> { c1.path }); db.saveMarked(c1); }
public void getMarked(chapterInfo c) { c.markedIndexs = new List <int>(); string key = c.path; chapterRec rec = findRec(key); if (rec == null) { return; } var arr = rec.marked.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries); foreach (var i in arr) { c.markedIndexs.Add(int.Parse(i)); } }
public void saveMarked(chapterInfo c) { string key = c.path; chapterRec rec = findRec(key); if (rec != null) { rec.marked = string.Join(";", c.markedIndexs); updateMarked(rec); } else { var newrec = new chapterRec() { key = c.path, marked = string.Join(";", c.markedIndexs) }; addMarked(newrec); m_cache.Add(key, newrec); m_dict.Add(key, newrec); } }