Rainy.Db.DbEncryptedStorage.GetNotes C# (CSharp) Method

GetNotes() public method

public GetNotes ( ) : Note>.Dictionary
return Note>.Dictionary
        public override Dictionary<string, Note> GetNotes()
        {
            var notes = base.GetDBNotes ();
            notes.ForEach (n => DecryptNoteBody (n));
            var dict = notes.ToDictionary (n => n.Guid, n => n.ToDTONote ().ToTomboyNote ());
            return dict;
        }

Usage Example

        public void StorageCanBeReusedAfterReEncryptNotes()
        {
            DbEncryptedStorage storage = new DbEncryptedStorage (this.connFactory, this.testUser, key);
            var sample_notes = DbStorageTests.GetSampleNotes ();
            foreach(var note in sample_notes) {
                storage.SaveNote (note);
            }
            storage.Dispose ();

            storage = new DbEncryptedStorage (connFactory, testUser, key);
            var new_key = CryptoHelper.Create256BitLowerCaseHexKey (new RNGCryptoServiceProvider ());

            storage.ReEncryptAllNotes (new_key);
            var decrypted_notes = storage.GetNotes ();

            foreach (var note in sample_notes) {
                Assert.AreEqual (note.Text, decrypted_notes.Values.First (n => n.Guid == note.Guid).Text);
            }
        }