move DictionaryToList into Utilities;

This commit is contained in:
2013-06-27 00:37:30 +02:00
parent 678a8dfd44
commit d51410de06
5 changed files with 31 additions and 30 deletions
@@ -3,6 +3,7 @@ using System;
using System.Collections.Generic;
using System.Reflection;
using System.Runtime.Serialization;
using ServiceStack.Text;
namespace PocketSharp.Models
{
+4 -4
View File
@@ -79,13 +79,13 @@ namespace PocketSharp.Models
[IgnoreDataMember]
public List<PocketTag> Tags
{
get { return PocketClient.DictionaryToList<PocketTag>(_TagDictionary); }
get { return Utilities.DictionaryToList<PocketTag>(_TagDictionary); }
}
[IgnoreDataMember]
public List<PocketImage> Images
{
get { return PocketClient.DictionaryToList<PocketImage>(_ImageDictionary); }
get { return Utilities.DictionaryToList<PocketImage>(_ImageDictionary); }
}
[IgnoreDataMember]
@@ -97,13 +97,13 @@ namespace PocketSharp.Models
[IgnoreDataMember]
public List<PocketVideo> Videos
{
get { return PocketClient.DictionaryToList<PocketVideo>(_VideoDictionary); }
get { return Utilities.DictionaryToList<PocketVideo>(_VideoDictionary); }
}
[IgnoreDataMember]
public List<PocketAuthor> Authors
{
get { return PocketClient.DictionaryToList<PocketAuthor>(_AuthorDictionary); }
get { return Utilities.DictionaryToList<PocketAuthor>(_AuthorDictionary); }
}
}
}
+1 -1
View File
@@ -19,7 +19,7 @@ namespace PocketSharp.Models
[IgnoreDataMember]
public List<PocketItem> Items
{
get { return PocketClient.DictionaryToList<PocketItem>(_ItemDictionary); }
get { return Utilities.DictionaryToList<PocketItem>(_ItemDictionary); }
}
}
}
-25
View File
@@ -253,30 +253,5 @@ namespace PocketSharp
throw new APIException("Error retrieving response", response.ErrorException);
}
}
/// <summary>
/// Convert a dictionary to a list
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="items">The items.</param>
/// <returns></returns>
internal static List<T> DictionaryToList<T>(Dictionary<string, T> items) where T : new()
{
if(items == null)
{
return null;
}
var itemEnumerator = items.GetEnumerator();
List<T> list = new List<T>();
while (itemEnumerator.MoveNext())
{
list.Add(itemEnumerator.Current.Value);
}
return list;
}
}
}
+25
View File
@@ -40,5 +40,30 @@ namespace PocketSharp
Type = type
};
}
/// <summary>
/// Convert a dictionary to a list
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="items">The items.</param>
/// <returns></returns>
public static List<T> DictionaryToList<T>(Dictionary<string, T> items) where T : new()
{
if (items == null)
{
return null;
}
var itemEnumerator = items.GetEnumerator();
List<T> list = new List<T>();
while (itemEnumerator.MoveNext())
{
list.Add(itemEnumerator.Current.Value);
}
return list;
}
}
}