/// <summary> /// Videoes the library callback manager. /// </summary> /// <param name="requestState">State of the request.</param> private void VideoLibraryCallbackManager(XRequestState requestState) { object returnObject = null; VideoLibrary operation = GetMethod(requestState.RequestOperation); var query = JObject.Parse(requestState.ResponseData); JObject result = (JObject)query["result"]; switch (operation) { case VideoLibrary.Clean: returnObject = result.Values(0).ToString(); break; case VideoLibrary.Export: break; case VideoLibrary.GetEpisodeDetails: Episode episode = null; if (result["episodedetails"] != null) { JObject item = (JObject)result["episodedetails"]; episode = Episode.FromJsonObject(item); } returnObject = episode; break; case VideoLibrary.GetEpisodes: case VideoLibrary.GetRecentlyAddedEpisodes: var episodes = new Episodes(); episodes.LoadFromJsonObject(result); returnObject = episodes; break; case VideoLibrary.GetGenres: var genres = new Genres(); genres.LoadFromJsonObject(result); returnObject = genres; break; case VideoLibrary.GetMovieDetails: Movie movie = null; if (result["moviedetails"] != null) { JObject item = (JObject)result["moviedetails"]; movie = Movie.FromJsonObject(item); } returnObject = movie; break; case VideoLibrary.GetMovies: case VideoLibrary.GetRecentlyAddedMovies: var movies = new Movies(); movies.LoadFromJsonObject(result); returnObject = movies; break; case VideoLibrary.GetMovieSetDetails: MovieSetExtended movieSet = null; if (result["setdetails"] != null) { JObject item = (JObject)result["setdetails"]; movieSet = MovieSetExtended.FromJsonObject(item); } returnObject = movieSet; break; case VideoLibrary.GetMovieSets: var movieSets = new MovieSets(); movieSets.LoadFromJsonObject(result); returnObject = movieSets; break; case VideoLibrary.GetMusicVideoDetails: MusicVideo musicVideo = null; if (result["musicvideodetails"] != null) { JObject item = (JObject)result["musicvideodetails"]; musicVideo = MusicVideo.FromJsonObject(item); } returnObject = musicVideo; break; case VideoLibrary.GetMusicVideos: case VideoLibrary.GetRecentlyAddedMusicVideos: var musicVideos = new MusicVideos(); musicVideos.LoadFromJsonObject(result); returnObject = musicVideos; break; case VideoLibrary.GetSeasons: var seasons = new Seasons(); seasons.LoadFromJsonObject(result); returnObject = seasons; break; case VideoLibrary.GetTVShowDetails: TvShow tvShow = null; if (result["tvshowdetails"] != null) { JObject item = (JObject)result["tvshowdetails"]; tvShow = TvShow.FromJsonObject(item); } returnObject = tvShow; break; case VideoLibrary.GetTVShows: var tvShows = new TvShows(); tvShows.LoadFromJsonObject(result); returnObject = tvShows; break; case VideoLibrary.Scan: returnObject = result.Values(0).ToString(); break; } if (requestState.UserCallback != null) requestState.UserCallback(returnObject); }