From 278cf89a887e6ba47643cdb6ecf171a16fed2193 Mon Sep 17 00:00:00 2001 From: LukePulverenti Luke Pulverenti luke pulverenti Date: Fri, 24 Aug 2012 08:45:54 -0400 Subject: [PATCH] Changed some types to List to avoid having to call ToList for insertion purposes --- MediaBrowser.Api/HttpHandlers/VideoHandler.cs | 4 +-- .../Providers/AudioInfoProvider.cs | 6 ++-- .../ImageFromMediaLocationProvider.cs | 4 +-- .../Providers/VideoInfoProvider.cs | 2 +- .../Xml/BaseItemXmlParser.cs | 34 +++++++++---------- MediaBrowser.Model/Entities/BaseItem.cs | 8 ++--- MediaBrowser.Model/Entities/Video.cs | 4 +-- 7 files changed, 31 insertions(+), 31 deletions(-) diff --git a/MediaBrowser.Api/HttpHandlers/VideoHandler.cs b/MediaBrowser.Api/HttpHandlers/VideoHandler.cs index fd08e530d2..ab3d5a7932 100644 --- a/MediaBrowser.Api/HttpHandlers/VideoHandler.cs +++ b/MediaBrowser.Api/HttpHandlers/VideoHandler.cs @@ -48,7 +48,7 @@ namespace MediaBrowser.Api.HttpHandlers return true; } - AudioStream audioStream = (LibraryItem.AudioStreams ?? new AudioStream[] { }).FirstOrDefault(); + AudioStream audioStream = (LibraryItem.AudioStreams ?? new List()).FirstOrDefault(); if (audioStream != null) { @@ -121,7 +121,7 @@ namespace MediaBrowser.Api.HttpHandlers private string GetAudioArguments(string outputFormat) { - AudioStream audioStream = (LibraryItem.AudioStreams ?? new AudioStream[] { }).FirstOrDefault(); + AudioStream audioStream = (LibraryItem.AudioStreams ?? new List()).FirstOrDefault(); if (audioStream == null) { diff --git a/MediaBrowser.Controller/Providers/AudioInfoProvider.cs b/MediaBrowser.Controller/Providers/AudioInfoProvider.cs index 4166cb1526..98168ba865 100644 --- a/MediaBrowser.Controller/Providers/AudioInfoProvider.cs +++ b/MediaBrowser.Controller/Providers/AudioInfoProvider.cs @@ -96,7 +96,7 @@ namespace MediaBrowser.Controller.Providers if (!string.IsNullOrEmpty(composer)) { - var list = (audio.People ?? new PersonInfo[] { }).ToList(); + var list = audio.People ?? new List(); list.Add(new PersonInfo() { Name = composer, Type = "Composer" }); audio.People = list; } @@ -127,7 +127,7 @@ namespace MediaBrowser.Controller.Providers if (!string.IsNullOrEmpty(val)) { - var list = (audio.Studios ?? new string[] { }).ToList(); + var list = audio.Studios ?? new List(); list.AddRange(val.Split('/')); audio.Studios = list; } @@ -139,7 +139,7 @@ namespace MediaBrowser.Controller.Providers if (!string.IsNullOrEmpty(val)) { - var list = (audio.Genres ?? new string[] { }).ToList(); + var list = audio.Genres ?? new List(); list.AddRange(val.Split('/')); audio.Genres = list; } diff --git a/MediaBrowser.Controller/Providers/ImageFromMediaLocationProvider.cs b/MediaBrowser.Controller/Providers/ImageFromMediaLocationProvider.cs index 242a139efc..b0b01404d5 100644 --- a/MediaBrowser.Controller/Providers/ImageFromMediaLocationProvider.cs +++ b/MediaBrowser.Controller/Providers/ImageFromMediaLocationProvider.cs @@ -32,7 +32,7 @@ namespace MediaBrowser.Controller.Providers if (baseItem != null) { - return Task.Run(() => { PopulateImages(baseItem, args); }); + return Task.Run(() => { PopulateBaseItemImages(baseItem, args); }); } else { @@ -74,7 +74,7 @@ namespace MediaBrowser.Controller.Providers /// /// Fills in image paths based on files win the folder /// - private void PopulateImages(BaseItem item, ItemResolveEventArgs args) + private void PopulateBaseItemImages(BaseItem item, ItemResolveEventArgs args) { List backdropFiles = new List(); diff --git a/MediaBrowser.Controller/Providers/VideoInfoProvider.cs b/MediaBrowser.Controller/Providers/VideoInfoProvider.cs index 9b5a8933df..d95f3032d8 100644 --- a/MediaBrowser.Controller/Providers/VideoInfoProvider.cs +++ b/MediaBrowser.Controller/Providers/VideoInfoProvider.cs @@ -128,7 +128,7 @@ namespace MediaBrowser.Controller.Providers audio.Language = AudioInfoProvider.GetDictionaryValue(stream.tags, "language"); - List streams = (video.AudioStreams ?? new AudioStream[] { }).ToList(); + List streams = video.AudioStreams ?? new List(); streams.Add(audio); video.AudioStreams = streams; } diff --git a/MediaBrowser.Controller/Xml/BaseItemXmlParser.cs b/MediaBrowser.Controller/Xml/BaseItemXmlParser.cs index 50520ac258..e2ed60b4e0 100644 --- a/MediaBrowser.Controller/Xml/BaseItemXmlParser.cs +++ b/MediaBrowser.Controller/Xml/BaseItemXmlParser.cs @@ -90,7 +90,7 @@ namespace MediaBrowser.Controller.Xml case "TagLine": { - var list = (item.Taglines ?? new string[] { }).ToList(); + var list = item.Taglines ?? new List(); var tagline = reader.ReadElementContentAsString(); if (!list.Contains(tagline)) @@ -135,10 +135,10 @@ namespace MediaBrowser.Controller.Xml case "Genre": { - var genres = (item.Genres ?? new string[] { }).ToList(); - genres.AddRange(GetSplitValues(reader.ReadElementContentAsString(), '|')); + var list = item.Genres ?? new List(); + list.AddRange(GetSplitValues(reader.ReadElementContentAsString(), '|')); - item.Genres = genres; + item.Genres = list; break; } @@ -148,16 +148,16 @@ namespace MediaBrowser.Controller.Xml case "Network": { - var studios = (item.Studios ?? new string[] { }).ToList(); - studios.AddRange(GetSplitValues(reader.ReadElementContentAsString(), '|')); + var list = item.Studios ?? new List(); + list.AddRange(GetSplitValues(reader.ReadElementContentAsString(), '|')); - item.Studios = studios; + item.Studios = list; break; } case "Director": { - var list = (item.People ?? new PersonInfo[] { }).ToList(); + var list = item.People ?? new List(); list.AddRange(GetSplitValues(reader.ReadElementContentAsString(), '|').Select(v => new PersonInfo() { Name = v, Type = "Director" })); item.People = list; @@ -165,7 +165,7 @@ namespace MediaBrowser.Controller.Xml } case "Writer": { - var list = (item.People ?? new PersonInfo[] { }).ToList(); + var list = item.People ?? new List(); list.AddRange(GetSplitValues(reader.ReadElementContentAsString(), '|').Select(v => new PersonInfo() { Name = v, Type = "Writer" })); item.People = list; @@ -175,7 +175,7 @@ namespace MediaBrowser.Controller.Xml case "Actors": case "GuestStars": { - var list = (item.People ?? new PersonInfo[] { }).ToList(); + var list = item.People ?? new List(); list.AddRange(GetSplitValues(reader.ReadElementContentAsString(), '|').Select(v => new PersonInfo() { Name = v, Type = "Actor" })); item.People = list; @@ -309,7 +309,7 @@ namespace MediaBrowser.Controller.Xml { AudioStream stream = FetchMediaInfoAudio(reader.ReadSubtree()); - List streams = (item.AudioStreams ?? new AudioStream[] { }).ToList(); + List streams = item.AudioStreams ?? new List(); streams.Add(stream); item.AudioStreams = streams; @@ -324,7 +324,7 @@ namespace MediaBrowser.Controller.Xml { SubtitleStream stream = FetchMediaInfoSubtitles(reader.ReadSubtree()); - List streams = (item.Subtitles ?? new SubtitleStream[] { }).ToList(); + List streams = item.Subtitles ?? new List(); streams.Add(stream); item.Subtitles = streams; @@ -490,7 +490,7 @@ namespace MediaBrowser.Controller.Xml private void FetchFromTaglinesNode(XmlReader reader, T item) { - List list = (item.Taglines ?? new string[] { }).ToList(); + var list = item.Taglines ?? new List(); reader.MoveToContent(); @@ -504,7 +504,7 @@ namespace MediaBrowser.Controller.Xml { string val = reader.ReadElementContentAsString(); - if (!string.IsNullOrWhiteSpace(val)) + if (!string.IsNullOrWhiteSpace(val) && !list.Contains(val)) { list.Add(val); } @@ -523,7 +523,7 @@ namespace MediaBrowser.Controller.Xml private void FetchFromGenresNode(XmlReader reader, T item) { - List list = (item.Genres ?? new string[] { }).ToList(); + var list = item.Genres ?? new List(); reader.MoveToContent(); @@ -556,7 +556,7 @@ namespace MediaBrowser.Controller.Xml private void FetchDataFromPersonsNode(XmlReader reader, T item) { - List list = (item.People ?? new PersonInfo[] { }).ToList(); + var list = item.People ?? new List(); reader.MoveToContent(); @@ -584,7 +584,7 @@ namespace MediaBrowser.Controller.Xml private void FetchFromStudiosNode(XmlReader reader, T item) { - List list = (item.Studios ?? new string[] { }).ToList(); + var list = item.Studios ?? new List(); reader.MoveToContent(); diff --git a/MediaBrowser.Model/Entities/BaseItem.cs b/MediaBrowser.Model/Entities/BaseItem.cs index 249dee3ac8..01a36593b0 100644 --- a/MediaBrowser.Model/Entities/BaseItem.cs +++ b/MediaBrowser.Model/Entities/BaseItem.cs @@ -56,13 +56,13 @@ namespace MediaBrowser.Model.Entities public string Language { get; set; } public string Overview { get; set; } - public IEnumerable Taglines { get; set; } + public List Taglines { get; set; } - public IEnumerable People { get; set; } + public List People { get; set; } - public IEnumerable Studios { get; set; } + public List Studios { get; set; } - public IEnumerable Genres { get; set; } + public List Genres { get; set; } public string DisplayMediaType { get; set; } diff --git a/MediaBrowser.Model/Entities/Video.cs b/MediaBrowser.Model/Entities/Video.cs index 6fa3f56fea..874b033ac8 100644 --- a/MediaBrowser.Model/Entities/Video.cs +++ b/MediaBrowser.Model/Entities/Video.cs @@ -6,8 +6,8 @@ namespace MediaBrowser.Model.Entities { public VideoType VideoType { get; set; } - public IEnumerable Subtitles { get; set; } - public IEnumerable AudioStreams { get; set; } + public List Subtitles { get; set; } + public List AudioStreams { get; set; } public int Height { get; set; } public int Width { get; set; }