[smuxi] Engine: implemented SqliteMessageBuffer.GetEnumerator()



commit 6c43b1a75ac966951062086ce0e89fbb5d430d66
Author: Mirco Bauer <meebey meebey net>
Date:   Wed Feb 26 23:05:31 2014 +0100

    Engine: implemented SqliteMessageBuffer.GetEnumerator()

 src/Engine/MessageBuffers/SqliteMessageBuffer.cs |   11 ++++++++++-
 1 files changed, 10 insertions(+), 1 deletions(-)
---
diff --git a/src/Engine/MessageBuffers/SqliteMessageBuffer.cs 
b/src/Engine/MessageBuffers/SqliteMessageBuffer.cs
index ddc2a62..78975bd 100644
--- a/src/Engine/MessageBuffers/SqliteMessageBuffer.cs
+++ b/src/Engine/MessageBuffers/SqliteMessageBuffer.cs
@@ -150,7 +150,16 @@ namespace Smuxi.Engine
 
         public override IEnumerator<MessageModel> GetEnumerator()
         {
-            throw new NotImplementedException ();
+            using (var cmd = Connection.CreateCommand()) {
+                cmd.CommandText = "SELECT JSON FROM Messages";
+
+                var reader = cmd.ExecuteReader();
+                while (reader.Read()) {
+                    var json = (string) reader["JSON"];
+                    var dto = JsonSerializer.DeserializeFromString<MessageDtoModelV1>(json);
+                    yield return dto.ToMessage();
+                }
+            }
         }
 
         public override int IndexOf(MessageModel item)


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]