Cleanup in Images classes

Cleanup in some class files (formatting mostly)
This commit is contained in:
Michael Bisbjerg 2013-11-08 01:29:12 +01:00
parent d232769de2
commit 8764a96d21
14 changed files with 62 additions and 47 deletions

View File

@ -19,27 +19,27 @@ namespace TMDbLib.Client
/// </summary>
public string DefaultCountry { get; set; }
/// <summary>
/// The maximum number of times a call to TMDb will be retied
/// </summary>
/// <remarks>Default is 0</remarks>
public int MaxRetryCount
{
get { return _client.MaxRetryCount; }
set { _client.MaxRetryCount = value; }
}
/// <summary>
/// The maximum number of times a call to TMDb will be retied
/// </summary>
/// <remarks>Default is 0</remarks>
public int MaxRetryCount
{
get { return _client.MaxRetryCount; }
set { _client.MaxRetryCount = value; }
}
/// <summary>
/// The base number of seconds that will be waited between retry attempts.
/// Each retry will take progressively longer to give the service a chance to recover from what ever the problem is.
/// Formula: RetryAttempt * RetryWaitTimeInSeconds, this is the amount of time in seconds the application will wait before retrying
/// </summary>
/// <remarks>Default is 10</remarks>
public int RetryWaitTimeInSeconds
{
get { return _client.RetryWaitTimeInSeconds; }
set { _client.RetryWaitTimeInSeconds = value; }
}
/// <summary>
/// The base number of seconds that will be waited between retry attempts.
/// Each retry will take progressively longer to give the service a chance to recover from what ever the problem is.
/// Formula: RetryAttempt * RetryWaitTimeInSeconds, this is the amount of time in seconds the application will wait before retrying
/// </summary>
/// <remarks>Default is 10</remarks>
public int RetryWaitTimeInSeconds
{
get { return _client.RetryWaitTimeInSeconds; }
set { _client.RetryWaitTimeInSeconds = value; }
}
public TMDbConfig Config
{
@ -56,7 +56,7 @@ namespace TMDbLib.Client
private const string ApiVersion = "3";
private const string ProductionUrl = "api.themoviedb.org";
private TMDbRestClient _client;
private TMDbRestClient _client;
private TMDbConfig _config;
public TMDbClient(string apiKey, bool useSsl = false, string baseUrl = ProductionUrl)
@ -72,11 +72,11 @@ namespace TMDbLib.Client
ApiKey = apiKey;
string httpScheme = useSsl ? "https" : "http";
_client = new TMDbRestClient(String.Format("{0}://{1}/{2}/",httpScheme, baseUrl, ApiVersion));
_client = new TMDbRestClient(String.Format("{0}://{1}/{2}/", httpScheme, baseUrl, ApiVersion));
_client.AddDefaultParameter("api_key", apiKey);
_client.ClearHandlers();
_client.AddHandler("application/json", new JsonDeserializer());
_client.AddHandler("application/json", new JsonDeserializer());
}
public void GetConfig()

View File

@ -33,7 +33,7 @@ namespace TMDbLib.Client
req.AddParameter("append_to_response", appends);
req.DateFormat = "yyyy-MM-dd";
IRestResponse<Collection> resp = _client.Get<Collection>(req);
return resp.Data;

View File

@ -25,7 +25,7 @@ namespace TMDbLib.Client
if (dateFormat != null)
req.DateFormat = dateFormat;
IRestResponse<T> resp = _client.Get<T>(req);
return resp.Data;

View File

@ -65,9 +65,9 @@ namespace TMDbLib.Client
/// If specified the api will attempt to return a localized result. ex: en,it,es.
/// For images this means that the image might contain language specifc text
/// </param>
public Images GetTvEpisodeImages(int tvShowId, int seasonNumber, int episodeNumber, string language = null)
public StillImages GetTvEpisodeImages(int tvShowId, int seasonNumber, int episodeNumber, string language = null)
{
return GetTvEpisodeMethod<Images>(tvShowId, seasonNumber, episodeNumber, TvEpisodeMethods.Images, language: language);
return GetTvEpisodeMethod<StillImages>(tvShowId, seasonNumber, episodeNumber, TvEpisodeMethods.Images, language: language);
}
/// <summary>
@ -87,7 +87,7 @@ namespace TMDbLib.Client
req.AddUrlSegment("id", tvShowId.ToString(CultureInfo.InvariantCulture));
req.AddUrlSegment("season_number", seasonNumber.ToString(CultureInfo.InvariantCulture));
req.AddUrlSegment("episode_number", episodeNumber.ToString(CultureInfo.InvariantCulture));
req.AddUrlSegment("method", tvShowMethod.GetDescription());
if (dateFormat != null)

View File

@ -62,9 +62,9 @@ namespace TMDbLib.Client
/// If specified the api will attempt to return a localized result. ex: en,it,es.
/// For images this means that the image might contain language specifc text
/// </param>
public Images GetTvSeasonImages(int tvShowId, int seasonNumber, string language = null)
public PosterImages GetTvSeasonImages(int tvShowId, int seasonNumber, string language = null)
{
return GetTvSeasonMethod<Images>(tvShowId, seasonNumber, TvSeasonMethods.Images, language: language);
return GetTvSeasonMethod<PosterImages>(tvShowId, seasonNumber, TvSeasonMethods.Images, language: language);
}
/// <summary>

View File

@ -98,9 +98,9 @@ namespace TMDbLib.Client
/// If specified the api will attempt to return a localized result. ex: en,it,es.
/// For images this means that the image might contain language specifc text
/// </param>
public Images GetTvShowImages(int id, string language = null)
public ImagesWithId GetTvShowImages(int id, string language = null)
{
return GetTvShowMethod<Images>(id, TvShowMethods.Images, language: language);
return GetTvShowMethod<ImagesWithId>(id, TvShowMethods.Images, language: language);
}
/// <summary>

View File

@ -4,9 +4,7 @@ namespace TMDbLib.Objects.General
{
public class Images
{
public int Id { get; set; }
public List<ImageData> Backdrops { get; set; }
public List<ImageData> Posters { get; set; }
public List<ImageData> Stills { get; set; }
}
}

View File

@ -0,0 +1,10 @@
using System.Collections.Generic;
namespace TMDbLib.Objects.General
{
public class PosterImages
{
public int Id { get; set; }
public List<ImageData> Posters { get; set; }
}
}

View File

@ -0,0 +1,10 @@
using System.Collections.Generic;
namespace TMDbLib.Objects.General
{
public class StillImages
{
public int Id { get; set; }
public List<ImageData> Stills { get; set; }
}
}

View File

@ -44,6 +44,8 @@
<Compile Include="Client\TMDbClientTvEpisodes.cs" />
<Compile Include="Client\TMDbClientTvSeasons.cs" />
<Compile Include="Client\TMDbClientTvShows.cs" />
<Compile Include="Objects\General\PosterImages.cs" />
<Compile Include="Objects\General\StillImages.cs" />
<Compile Include="Objects\Genres\GenreContainer.cs" />
<Compile Include="Objects\Changes\ChangesListItem.cs" />
<Compile Include="Objects\Companies\Company.cs" />

View File

@ -25,9 +25,10 @@ namespace TMDbLibTests
_config = new TestConfig();
_methods = new Dictionary<PersonMethods, Func<Person, object>>();
_methods[PersonMethods.Credits] = movie => movie.Credits;
_methods[PersonMethods.Changes] = movie => movie.Changes;
_methods[PersonMethods.Images] = movie => movie.Images;
_methods[PersonMethods.TvCredits] = person => person.Credits;
_methods[PersonMethods.MovieCredits] = person => person.Credits;
_methods[PersonMethods.Changes] = person => person.Changes;
_methods[PersonMethods.Images] = person => person.Images;
}
[TestMethod]

View File

@ -66,10 +66,8 @@ namespace TMDbLibTests
[TestMethod]
public void TestTvEpisodeSeparateExtrasImages()
{
Images images = _config.Client.GetTvEpisodeImages(BreakingBad, 1, 1);
StillImages images = _config.Client.GetTvEpisodeImages(BreakingBad, 1, 1);
Assert.IsNotNull(images);
Assert.IsNull(images.Backdrops);
Assert.IsNull(images.Posters);
Assert.IsNotNull(images.Stills);
}

View File

@ -26,7 +26,6 @@ namespace TMDbLibTests
_methods[TvSeasonMethods.Credits] = tvSeason => tvSeason.Credits;
_methods[TvSeasonMethods.Images] = tvSeason => tvSeason.Images;
_methods[TvSeasonMethods.ExternalIds] = tvSeason => tvSeason.ExternalIds;
}
[TestMethod]
@ -66,11 +65,9 @@ namespace TMDbLibTests
[TestMethod]
public void TestTvSeasonSeparateExtrasImages()
{
Images images = _config.Client.GetTvSeasonImages(BreakingBad,1);
PosterImages images = _config.Client.GetTvSeasonImages(BreakingBad, 1);
Assert.IsNotNull(images);
Assert.IsNull(images.Backdrops);
Assert.IsNotNull(images.Posters);
Assert.IsNull(images.Stills);
}
[TestMethod]
@ -101,7 +98,7 @@ namespace TMDbLibTests
private void TestBreakingBadBaseProperties(TvSeason tvSeason)
{
Assert.IsNotNull(tvSeason);
Assert.IsNotNull(tvSeason.Id);
Assert.IsNotNull(tvSeason.Id);
Assert.AreEqual(1, tvSeason.SeasonNumber);
Assert.AreEqual("Season 1", tvSeason.Name);
Assert.IsNotNull(tvSeason.AirDate);

View File

@ -66,11 +66,10 @@ namespace TMDbLibTests
[TestMethod]
public void TestTvShowSeparateExtrasImages()
{
Images images = _config.Client.GetTvShowImages(BreakingBad);
ImagesWithId images = _config.Client.GetTvShowImages(BreakingBad);
Assert.IsNotNull(images);
Assert.IsNotNull(images.Backdrops);
Assert.IsNotNull(images.Posters);
Assert.IsNull(images.Stills);
}
[TestMethod]