public void HandleSearchResult(IMetadata result)
        {
            try
            {
                if (result == null)
                    return;

                if (result is IArtist)
                {
                    var artistKey = result.Location.ToString();
                    if (!artistResults.ContainsKey(artistKey))
                    {
                        var artistViewModel = new ArtistViewModel(mediaItemController, result as IArtist); //result.Location, result.Name, result.Summary, result.FromDate, result.ToDate, result.Thumbnail, result.ThumbnailData);
                        var resultViewModel = new SearchResultViewModel(artistViewModel);
                        artistResults.Add(artistKey, resultViewModel);
                        AddResult(resultViewModel);
                    }
                }
                else if (result is IAlbum)
                {
                    var albumViewModel = new AlbumViewModel(mediaItemController, result as IAlbum); //result.Location, result.Name, result.Summary, result.Creator, result.CreatorName, result.FromDate, result.Thumbnail, result.ThumbnailData);

                    var artistKey = result.Creator.ToString();
                    var albumKey = result.Location.ToString();
                    if (!artistResults.ContainsKey(artistKey))
                    {
                        if (!albumResults.ContainsKey(albumKey))
                        {
                            var resultViewModel = new SearchResultViewModel(albumViewModel);
                            AddResult(resultViewModel);
                            albumResults.Add(albumKey, resultViewModel);
                        }
                    }
                    else
                    {
                        if (!albumResults.ContainsKey(albumKey))
                        {
                            var existing = artistResults[artistKey].Albums.Where(x => x.Id.ToString() == albumViewModel.Id.ToString()).FirstOrDefault();
                            if (existing == null)
                            {
                                AddAlbum(artistResults[artistKey], albumViewModel);
                            }
                        }
                    }
                }
                else if (result is ITrack)
                {
                    var trackViewModel = new TrackViewModel(mediaItemController, result as ITrack); //result.Location, result.Name, result.Summary, result.Number, result.Duration, result.FromDate, result.Creator, result.CreatorName, result.Catalog, result.CatalogName, result.Target, result.TargetType, result.Thumbnail, result.ThumbnailData);

                    var albumKey = result.Catalog.ToString();
                    var trackKey = result.Location.ToString();
                    if (!albumResults.ContainsKey(albumKey))
                    {
                        if (!trackResults.ContainsKey(trackKey))
                        {
                            var resultViewModel = new SearchResultViewModel(trackViewModel);
                            trackResults.Add(trackKey, resultViewModel);
                            AddResult(resultViewModel);
                        }
                    }
                    else
                    {
                        if (!trackResults.ContainsKey(trackKey))
                        {
                            //var existing = albumResults[albumKey].Tracks.Where(x => x.Album.ToString() == trackViewModel.Album.ToString()).FirstOrDefault();
                            //if (existing == null)
                            //{
                            AddTrack(albumResults[albumKey], trackViewModel);
                            //}
                        }
                    }
                }
                else if (result is IClip)
                {
                    var clipViewModel = new ClipViewModel(mediaItemController, result as IClip); //result.Location, result.Name, result.Summary, result.Number, result.Duration, result.Height, result.Width, result.FromDate, result.Creator, result.CreatorName, result.Catalog, result.CatalogName, result.Target, result.TargetType, result.Thumbnail, result.ThumbnailData);

                    var albumKey = result.Catalog.ToString();
                    var clipKey = result.Location.ToString();
                    if (!albumResults.ContainsKey(albumKey))
                    {
                        if (!clipResults.ContainsKey(clipKey))
                        {
                            var resultViewModel = new SearchResultViewModel(clipViewModel);
                            clipResults.Add(clipKey, resultViewModel);
                            AddResult(resultViewModel);
                        }
                    }
                    else
                    {
                        if (!clipResults.ContainsKey(clipKey))
                        {
                            //var existing = albumResults[albumKey].Tracks.Where(x => x.Album.ToString() == trackViewModel.Album.ToString()).FirstOrDefault();
                            //if (existing == null)
                            //{
                            AddClip(albumResults[albumKey], clipViewModel);
                            //}
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                logger.Error("  HandleSearchResults", ex);
            }
        }
        private void AddTrack(ISearchResultViewModel album, TrackViewModel track)
        {
            var existing = album.Tracks.Where(x => x.Id == track.Id).FirstOrDefault();
            if (existing != null)
                return;

            Action action = () => album.AddTrack(track);
            Dispatcher.Invoke(action, DispatcherPriority.DataBind);
        }