Exemplo n.º 1
0
        public static RdioResultSet ConvertListToRdioResultSet(IEnumerable<object> results)
        {
            var resultSet = new RdioResultSet();
            foreach (var result in results.Cast<IDictionary<string, object>>())
            {
                var rdioType = ParseRdioType((string) result["type"]);
                var rdioObject = ConvertDictionaryToRdioObject(result, rdioType);
                switch (rdioType)
                {
                    case RdioType.Album:
                        resultSet.Albums.Add(rdioObject as RdioAlbum);
                        break;
                    case RdioType.Artist:
                        resultSet.Artists.Add(rdioObject as RdioArtist);
                        break;
                    case RdioType.Playlist:
                        resultSet.Playlists.Add(rdioObject as RdioPlaylist);
                        break;
                    case RdioType.Track:
                        resultSet.Tracks.Add(rdioObject as RdioTrack);
                        break;
                    case RdioType.User:
                        resultSet.Users.Add(rdioObject as RdioUser);
                        break;
                    default:
                        break;
                }
            }

            return resultSet;
        }
Exemplo n.º 2
0
 public static RdioResultSet ConvertDictionaryToRdioResultSet(IEnumerable<KeyValuePair<string, object>> results)
 {
     var resultSet = new RdioResultSet();
     foreach (var kvp in results)
     {
         var rdioType = ParseRdioType(kvp.Key.Substring(0, 1));
         var d = (Dictionary<string,object>)kvp.Value;
         if (d == null) continue;
         var rdioObject = ConvertDictionaryToRdioObject(d, rdioType);
         switch (rdioType)
         {
             case RdioType.Album:
                 resultSet.Albums.Add(rdioObject as RdioAlbum);
                 break;
             case RdioType.Artist:
                 resultSet.Artists.Add(rdioObject as RdioArtist);
                 break;
             case RdioType.Playlist:
                 resultSet.Playlists.Add(rdioObject as RdioPlaylist);
                 break;
             case RdioType.Track:
                 resultSet.Tracks.Add(rdioObject as RdioTrack);
                 break;
             case RdioType.User:
                 resultSet.Users.Add(rdioObject as RdioUser);
                 break;
             default:
                 break;
         }
     }
     return resultSet;
 }