From d51410de06623cf58baa2ca7f8e63b2543047fc8 Mon Sep 17 00:00:00 2001 From: ceee Date: Thu, 27 Jun 2013 00:37:30 +0200 Subject: [PATCH] move DictionaryToList into Utilities; --- .../Models/Parameters/RetrieveParameters.cs | 1 + PocketSharp/Models/PocketItem.cs | 8 +++--- PocketSharp/Models/Response/Retrieve.cs | 2 +- PocketSharp/PocketClient.cs | 25 ------------------- PocketSharp/Utilities.cs | 25 +++++++++++++++++++ 5 files changed, 31 insertions(+), 30 deletions(-) diff --git a/PocketSharp/Models/Parameters/RetrieveParameters.cs b/PocketSharp/Models/Parameters/RetrieveParameters.cs index a5a76cb..737e423 100644 --- a/PocketSharp/Models/Parameters/RetrieveParameters.cs +++ b/PocketSharp/Models/Parameters/RetrieveParameters.cs @@ -3,6 +3,7 @@ using System; using System.Collections.Generic; using System.Reflection; using System.Runtime.Serialization; +using ServiceStack.Text; namespace PocketSharp.Models { diff --git a/PocketSharp/Models/PocketItem.cs b/PocketSharp/Models/PocketItem.cs index fde2ca1..ca1f3b6 100644 --- a/PocketSharp/Models/PocketItem.cs +++ b/PocketSharp/Models/PocketItem.cs @@ -79,13 +79,13 @@ namespace PocketSharp.Models [IgnoreDataMember] public List Tags { - get { return PocketClient.DictionaryToList(_TagDictionary); } + get { return Utilities.DictionaryToList(_TagDictionary); } } [IgnoreDataMember] public List Images { - get { return PocketClient.DictionaryToList(_ImageDictionary); } + get { return Utilities.DictionaryToList(_ImageDictionary); } } [IgnoreDataMember] @@ -97,13 +97,13 @@ namespace PocketSharp.Models [IgnoreDataMember] public List Videos { - get { return PocketClient.DictionaryToList(_VideoDictionary); } + get { return Utilities.DictionaryToList(_VideoDictionary); } } [IgnoreDataMember] public List Authors { - get { return PocketClient.DictionaryToList(_AuthorDictionary); } + get { return Utilities.DictionaryToList(_AuthorDictionary); } } } } diff --git a/PocketSharp/Models/Response/Retrieve.cs b/PocketSharp/Models/Response/Retrieve.cs index 1580d28..1232fa6 100644 --- a/PocketSharp/Models/Response/Retrieve.cs +++ b/PocketSharp/Models/Response/Retrieve.cs @@ -19,7 +19,7 @@ namespace PocketSharp.Models [IgnoreDataMember] public List Items { - get { return PocketClient.DictionaryToList(_ItemDictionary); } + get { return Utilities.DictionaryToList(_ItemDictionary); } } } } diff --git a/PocketSharp/PocketClient.cs b/PocketSharp/PocketClient.cs index c05ea59..0b7ee13 100644 --- a/PocketSharp/PocketClient.cs +++ b/PocketSharp/PocketClient.cs @@ -253,30 +253,5 @@ namespace PocketSharp throw new APIException("Error retrieving response", response.ErrorException); } } - - - /// - /// Convert a dictionary to a list - /// - /// - /// The items. - /// - internal static List DictionaryToList(Dictionary items) where T : new() - { - if(items == null) - { - return null; - } - - var itemEnumerator = items.GetEnumerator(); - List list = new List(); - - while (itemEnumerator.MoveNext()) - { - list.Add(itemEnumerator.Current.Value); - } - - return list; - } } } diff --git a/PocketSharp/Utilities.cs b/PocketSharp/Utilities.cs index 3beedd7..9736e0e 100644 --- a/PocketSharp/Utilities.cs +++ b/PocketSharp/Utilities.cs @@ -40,5 +40,30 @@ namespace PocketSharp Type = type }; } + + + /// + /// Convert a dictionary to a list + /// + /// + /// The items. + /// + public static List DictionaryToList(Dictionary items) where T : new() + { + if (items == null) + { + return null; + } + + var itemEnumerator = items.GetEnumerator(); + List list = new List(); + + while (itemEnumerator.MoveNext()) + { + list.Add(itemEnumerator.Current.Value); + } + + return list; + } } }