示例#1
0
        private static void noteCreated(NoteEntity newNoteEntity)
        {
            var belongNotebookPath = newNoteEntity.NotebookPath;

            lock (LockObj)
            {
                NoteCollection noteCollection;
                if (NoteCollectionDict.TryGetValue(belongNotebookPath, out noteCollection))
                {
                    var flag = false;
                    for (var i = 0; i < noteCollection.Count; i++)
                    {
                        if (noteCollection[i].ModifyTime >= newNoteEntity.ModifyTime)
                        {
                            continue;
                        }
                        noteCollection.Insert(i, newNoteEntity);
                        flag = true;
                        break;
                    }
                    if (!flag)
                    {
                        noteCollection.Add(newNoteEntity);
                    }
                }
                else
                {
                    noteCollection = new NoteCollection {
                        newNoteEntity
                    };
                    NoteCollectionDict.Add(belongNotebookPath, noteCollection);
                }
            }
        }
示例#2
0
        public static NoteCollection GetNoteCollection(string notebookPath)
        {
            if (string.IsNullOrEmpty(notebookPath))
            {
                throw new ArgumentNullException("notebookPath");
            }
            lock (LockObj)
            {
                NoteCollection noteCollection;

                if (!NoteCollectionDict.TryGetValue(notebookPath, out noteCollection))
                {
                    noteCollection = new NoteCollection(NoteDao.Inst.GetNotesByNotebookPath(notebookPath));
                    NoteCollectionDict.Add(notebookPath, noteCollection);
                }
                noteCollection.Sort(n => n.ModifyTime, ListSortDirection.Descending);
                return(noteCollection);
            }
        }
示例#3
0
 private static void initNoteListDictAsync()
 {
     Task.Run(() =>
     {
         var notebooks = NotebookDao.Inst.GetAllNotebook();
         if (null == notebooks)
         {
             return;
         }
         foreach (var nb in notebooks)
         {
             var noteCollection = new NoteCollection(NoteDao.Inst.GetNotesByNotebookPath(nb.Path));
             lock (LockObj)
             {
                 if (!NoteCollectionDict.ContainsKey(nb.Path))
                 {
                     NoteCollectionDict.Add(nb.Path, noteCollection);
                 }
             }
         }
     });
 }