changed images dictionary to be enum based

This commit is contained in:
Luke Pulverenti 2013-04-25 15:47:38 -04:00
parent 7a5a1511cc
commit 68d0181216
5 changed files with 19 additions and 32 deletions

View File

@ -299,12 +299,9 @@ namespace MediaBrowser.Controller.Dto
foreach (var image in item.Images)
{
ImageType type;
var type = image.Key;
if (Enum.TryParse(image.Key, true, out type))
{
dto.ImageTags[type] = Kernel.Instance.ImageManager.GetImageCacheTag(item, type, image.Value);
}
dto.ImageTags[type] = Kernel.Instance.ImageManager.GetImageCacheTag(item, type, image.Value);
}
}

View File

@ -111,14 +111,14 @@ namespace MediaBrowser.Controller.Entities.Audio
/// Gets or sets the images.
/// </summary>
/// <value>The images.</value>
public override Dictionary<string, string> Images
public override Dictionary<ImageType, string> Images
{
get
{
var images = base.Images;
string primaryImagePath;
if (images == null || !images.TryGetValue(ImageType.Primary.ToString(), out primaryImagePath))
if (images == null || !images.TryGetValue(ImageType.Primary, out primaryImagePath))
{
var image = Children.Select(c => c.PrimaryImagePath).FirstOrDefault(c => !string.IsNullOrEmpty(c));
@ -126,9 +126,9 @@ namespace MediaBrowser.Controller.Entities.Audio
{
if (images == null)
{
images = new Dictionary<string, string>();
images = new Dictionary<ImageType, string>();
}
images[ImageType.Primary.ToString()] = image;
images[ImageType.Primary] = image;
}
}

View File

@ -89,7 +89,7 @@ namespace MediaBrowser.Controller.Entities
/// Gets or sets the images.
/// </summary>
/// <value>The images.</value>
public virtual Dictionary<string, string> Images { get; set; }
public virtual Dictionary<ImageType, string> Images { get; set; }
/// <summary>
/// Gets or sets the date created.
@ -650,7 +650,7 @@ namespace MediaBrowser.Controller.Entities
/// <summary>
/// The _local trailers
/// </summary>
private List<Video> _localTrailers;
private List<Trailer> _localTrailers;
/// <summary>
/// The _local trailers initialized
/// </summary>
@ -664,7 +664,7 @@ namespace MediaBrowser.Controller.Entities
/// </summary>
/// <value>The local trailers.</value>
[IgnoreDataMember]
public List<Video> LocalTrailers
public List<Trailer> LocalTrailers
{
get
{
@ -708,7 +708,7 @@ namespace MediaBrowser.Controller.Entities
/// Loads local trailers from the file system
/// </summary>
/// <returns>List{Video}.</returns>
private List<Video> LoadLocalTrailers()
private List<Trailer> LoadLocalTrailers()
{
ItemResolveArgs resolveArgs;
@ -719,12 +719,12 @@ namespace MediaBrowser.Controller.Entities
catch (IOException ex)
{
Logger.ErrorException("Error getting ResolveArgs for {0}", ex, Path);
return new List<Video>();
return new List<Trailer>();
}
if (!resolveArgs.IsDirectory)
{
return new List<Video>();
return new List<Trailer>();
}
var folder = resolveArgs.GetFileSystemEntryByName(TrailerFolderName);
@ -732,7 +732,7 @@ namespace MediaBrowser.Controller.Entities
// Path doesn't exist. No biggie
if (folder == null)
{
return new List<Video>();
return new List<Trailer>();
}
IEnumerable<WIN32_FIND_DATA> files;
@ -744,13 +744,13 @@ namespace MediaBrowser.Controller.Entities
catch (IOException ex)
{
Logger.ErrorException("Error loading trailers for {0}", ex, Name);
return new List<Video>();
return new List<Trailer>();
}
return LibraryManager.ResolvePaths<Video>(files, null).Select(video =>
return LibraryManager.ResolvePaths<Trailer>(files, null).Select(video =>
{
// Try to retrieve it from the db. If we don't find it, use the resolved version
var dbItem = LibraryManager.RetrieveItem(video.Id) as Video;
var dbItem = LibraryManager.RetrieveItem(video.Id) as Trailer;
if (dbItem != null)
{
@ -1376,7 +1376,7 @@ namespace MediaBrowser.Controller.Entities
}
string val;
Images.TryGetValue(type.ToString(), out val);
Images.TryGetValue(type, out val);
return val;
}
@ -1417,7 +1417,7 @@ namespace MediaBrowser.Controller.Entities
throw new ArgumentException("Screenshots should be accessed using Item.Screenshots");
}
var typeKey = type.ToString();
var typeKey = type;
// If it's null remove the key from the dictionary
if (string.IsNullOrEmpty(path))
@ -1435,7 +1435,7 @@ namespace MediaBrowser.Controller.Entities
// Ensure it exists
if (Images == null)
{
Images = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
Images = new Dictionary<ImageType, string>();
}
Images[typeKey] = path;

View File

@ -24,11 +24,6 @@ namespace MediaBrowser.Controller.Providers.MediaInfo
{
}
/// <summary>
/// The true task result
/// </summary>
protected static readonly Task<bool> TrueTaskResult = Task.FromResult(true);
/// <summary>
/// Supportses the specified item.
/// </summary>

View File

@ -50,11 +50,6 @@ namespace MediaBrowser.Controller.Providers.TV
}
}
/// <summary>
/// The true task result
/// </summary>
protected static readonly Task<bool> TrueTaskResult = Task.FromResult(true);
/// <summary>
/// Fetches metadata and returns true or false indicating if any work that requires persistence was done
/// </summary>