當前位置: 首頁>>代碼示例>>C#>>正文


C# Note.PopulateWith方法代碼示例

本文整理匯總了C#中Tomboy.Note.PopulateWith方法的典型用法代碼示例。如果您正苦於以下問題:C# Note.PopulateWith方法的具體用法?C# Note.PopulateWith怎麽用?C# Note.PopulateWith使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Tomboy.Note的用法示例。


在下文中一共展示了Note.PopulateWith方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: Put

        public object Put(PutNotesRequest request)
        {
            try {
                using (var note_repo = GetNotes (request.Username)) {

                    // constraint taken from snowy source code at http://git.gnome.org/browse/snowy/tree/api/handlers.py:143
                    var new_sync_rev = note_repo.Manifest.LastSyncRevision + 1;

                    // TODO LatestSyncRevision is not correctly SERIALIZED
                    Logger.DebugFormat ("client sent LatestSyncRevision: {0}", request.LatestSyncRevision);

                    // TODO sanitize LatestSyncRevision sent by client - we don't need it to update notes
                    // but a wrong LatestSyncRevision may be an indicator for a bug in the client

                    //if (new_sync_rev != note_repo.Manifest.LatestSyncRevision + 1)
                    //	throw new Exception ("Sync revisions differ by more than one, sth went wrong");

                    foreach (var dto_note in request.Notes) {
                        var note = new Note ("note://tomboy/" + dto_note.Guid);
                        // map from the DTO
                        note.PopulateWith (dto_note);

                        if (dto_note.Command == "delete") {
                            note_repo.Engine.DeleteNote (note);
                        } else {
                            // track the revision of the note
                            note_repo.Manifest.NoteRevisions [dto_note.Guid] = (int)new_sync_rev;
                            note_repo.Engine.SaveNote (note, false);
                        }
                    }

                    // only update the sync revision if changes were sent
                    if (request.Notes.Count > 0)
                        note_repo.Manifest.LastSyncRevision = new_sync_rev;

                    var notes_to_return = NotesService.GetStoredNotes (note_repo);
                    notes_to_return.LatestSyncRevision = new_sync_rev;
                    return notes_to_return;
                }
            } catch (Exception e) {
                // log the error and rethrow
                Logger.DebugFormat ("CAUGHT EXCEPTION: {0} {1}", e.Message, e.StackTrace);
                throw e;
            }
        }
開發者ID:jonpolak,項目名稱:Rainy,代碼行數:45,代碼來源:NoteService.cs


注:本文中的Tomboy.Note.PopulateWith方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。