The Free Software Media System - Server Backend & API
Some minor code cleanups
LukePulverenti Luke Pulverenti luke pulverenti670a53258ef7
diff --git a/MediaBrowser.Api/ApiService.cs b/MediaBrowser.Api/ApiService.csindex 88af0f8134..938a34f60c 100644--- a/MediaBrowser.Api/ApiService.cs+++ b/MediaBrowser.Api/ApiService.cs@@ -3,7 +3,6 @@ using MediaBrowser.Controller.Entities;using MediaBrowser.Controller.Entities.Movies;using MediaBrowser.Controller.Entities.TV;using MediaBrowser.Model.DTO;-using MediaBrowser.Model.Entities;using System;using System.Collections.Generic;using System.Linq;@@ -33,9 +32,9 @@ namespace MediaBrowser.Api/// <param name="logActivity">Whether or not to update the user's LastActivityDate</param>public static User GetUserById(string id, bool logActivity){- Guid guid = new Guid(id);+ var guid = new Guid(id);- User user = Kernel.Instance.Users.FirstOrDefault(u => u.Id == guid);+ var user = Kernel.Instance.Users.FirstOrDefault(u => u.Id == guid);if (logActivity){@@ -73,11 +72,11 @@ namespace MediaBrowser.Api/// <summary>/// Converts a BaseItem to a DTOBaseItem/// </summary>- public async static Task<DTOBaseItem> GetDTOBaseItem(BaseItem item, User user,+ public async static Task<DtoBaseItem> GetDtoBaseItem(BaseItem item, User user,bool includeChildren = true,bool includePeople = true){- DTOBaseItem dto = new DTOBaseItem();+ DtoBaseItem dto = new DtoBaseItem();List<Task> tasks = new List<Task>();@@ -108,7 +107,7 @@ namespace MediaBrowser.Api/// <summary>/// Sets simple property values on a DTOBaseItem/// </summary>- private static void AttachBasicFields(DTOBaseItem dto, BaseItem item, User user)+ private static void AttachBasicFields(DtoBaseItem dto, BaseItem item, User user){dto.AspectRatio = item.AspectRatio;dto.BackdropCount = item.BackdropImagePaths == null ? 0 : item.BackdropImagePaths.Count();@@ -173,7 +172,7 @@ namespace MediaBrowser.Apidto.Type = item.GetType().Name;dto.UserRating = item.UserRating;- dto.UserData = GetDTOUserItemData(item.GetUserData(user, false));+ dto.UserData = GetDtoUserItemData(item.GetUserData(user, false));Folder folder = item as Folder;@@ -190,7 +189,7 @@ namespace MediaBrowser.Apiif (audio != null){- dto.AudioInfo = new AudioInfo()+ dto.AudioInfo = new AudioInfo{Album = audio.Album,AlbumArtist = audio.AlbumArtist,@@ -205,7 +204,7 @@ namespace MediaBrowser.Apiif (video != null){- dto.VideoInfo = new VideoInfo()+ dto.VideoInfo = new VideoInfo{Height = video.Height,Width = video.Width,@@ -232,7 +231,7 @@ namespace MediaBrowser.Api{DayOfWeek[] airDays = series.AirDays == null ? new DayOfWeek[] { } : series.AirDays.ToArray(); ;- dto.SeriesInfo = new SeriesInfo()+ dto.SeriesInfo = new SeriesInfo{AirDays = airDays,AirTime = series.AirTime,@@ -247,7 +246,7 @@ namespace MediaBrowser.Api{int specialFeatureCount = movie.SpecialFeatures == null ? 0 : movie.SpecialFeatures.Count();- dto.MovieInfo = new MovieInfo()+ dto.MovieInfo = new MovieInfo{SpecialFeatureCount = specialFeatureCount};@@ -257,12 +256,12 @@ namespace MediaBrowser.Api/// <summary>/// Attaches Studio DTO's to a DTOBaseItem/// </summary>- private static async Task AttachStudios(DTOBaseItem dto, BaseItem item)+ private static async Task AttachStudios(DtoBaseItem dto, BaseItem item){// Attach Studios by transforming them into BaseItemStudio (DTO)if (item.Studios != null){- Studio[] entities = await Task.WhenAll<Studio>(item.Studios.Select(c => Kernel.Instance.ItemController.GetStudio(c))).ConfigureAwait(false);+ Studio[] entities = await Task.WhenAll(item.Studios.Select(c => Kernel.Instance.ItemController.GetStudio(c))).ConfigureAwait(false);dto.Studios = new BaseItemStudio[entities.Length];@@ -283,7 +282,7 @@ namespace MediaBrowser.Api/// <summary>/// Attaches child DTO's to a DTOBaseItem/// </summary>- private static async Task AttachChildren(DTOBaseItem dto, BaseItem item, User user)+ private static async Task AttachChildren(DtoBaseItem dto, BaseItem item, User user){var folder = item as Folder;@@ -291,30 +290,30 @@ namespace MediaBrowser.Api{IEnumerable<BaseItem> children = folder.GetParentalAllowedChildren(user);- dto.Children = await Task.WhenAll<DTOBaseItem>(children.Select(c => GetDTOBaseItem(c, user, false, false))).ConfigureAwait(false);+ dto.Children = await Task.WhenAll(children.Select(c => GetDtoBaseItem(c, user, false, false))).ConfigureAwait(false);}}/// <summary>/// Attaches trailer DTO's to a DTOBaseItem/// </summary>- private static async Task AttachLocalTrailers(DTOBaseItem dto, BaseItem item, User user)+ private static async Task AttachLocalTrailers(DtoBaseItem dto, BaseItem item, User user){if (item.LocalTrailers != null && item.LocalTrailers.Any()){- dto.LocalTrailers = await Task.WhenAll<DTOBaseItem>(item.LocalTrailers.Select(c => GetDTOBaseItem(c, user, false, false))).ConfigureAwait(false);+ dto.LocalTrailers = await Task.WhenAll(item.LocalTrailers.Select(c => GetDtoBaseItem(c, user, false, false))).ConfigureAwait(false);}}/// <summary>/// Attaches People DTO's to a DTOBaseItem/// </summary>- private static async Task AttachPeople(DTOBaseItem dto, BaseItem item)+ private static async Task AttachPeople(DtoBaseItem dto, BaseItem item){// Attach People by transforming them into BaseItemPerson (DTO)if (item.People != null){- IEnumerable<Person> entities = await Task.WhenAll<Person>(item.People.Select(c => Kernel.Instance.ItemController.GetPerson(c.Key))).ConfigureAwait(false);+ IEnumerable<Person> entities = await Task.WhenAll(item.People.Select(c => Kernel.Instance.ItemController.GetPerson(c.Key))).ConfigureAwait(false);dto.People = item.People.Select(p =>{@@ -384,7 +383,7 @@ namespace MediaBrowser.Api/// </summary>public static IBNItem GetIBNItem(BaseEntity entity, int itemCount){- return new IBNItem()+ return new IBNItem{Id = entity.Id,BaseItemCount = itemCount,@@ -396,9 +395,9 @@ namespace MediaBrowser.Api/// <summary>/// Converts a User to a DTOUser/// </summary>- public static DTOUser GetDTOUser(User user)+ public static DtoUser GetDtoUser(User user){- return new DTOUser()+ return new DtoUser{Id = user.Id,Name = user.Name,@@ -412,14 +411,14 @@ namespace MediaBrowser.Api/// <summary>/// Converts a UserItemData to a DTOUserItemData/// </summary>- public static DTOUserItemData GetDTOUserItemData(UserItemData data)+ public static DtoUserItemData GetDtoUserItemData(UserItemData data){if (data == null){return null;}- return new DTOUserItemData()+ return new DtoUserItemData{IsFavorite = data.IsFavorite,Likes = data.Likes,diff --git a/MediaBrowser.Api/HttpHandlers/AudioHandler.cs b/MediaBrowser.Api/HttpHandlers/AudioHandler.csindex 3d17a3d6a2..9c16acd2ef 100644--- a/MediaBrowser.Api/HttpHandlers/AudioHandler.cs+++ b/MediaBrowser.Api/HttpHandlers/AudioHandler.cs@@ -86,7 +86,7 @@ namespace MediaBrowser.Api.HttpHandlers/// </summary>protected override string GetCommandLineArguments(){- List<string> audioTranscodeParams = new List<string>();+ var audioTranscodeParams = new List<string>();AudioOutputFormats outputFormat = GetConversionOutputFormat();diff --git a/MediaBrowser.Api/HttpHandlers/BaseMediaHandler.cs b/MediaBrowser.Api/HttpHandlers/BaseMediaHandler.csindex e87af76ea5..32fdb7efa2 100644--- a/MediaBrowser.Api/HttpHandlers/BaseMediaHandler.cs+++ b/MediaBrowser.Api/HttpHandlers/BaseMediaHandler.cs@@ -38,7 +38,7 @@ namespace MediaBrowser.Api.HttpHandlers}}- private TBaseItemType _LibraryItem;+ private TBaseItemType _libraryItem;/// <summary>/// Gets the library item that will be played, if any/// </summary>@@ -46,17 +46,17 @@ namespace MediaBrowser.Api.HttpHandlers{get{- if (_LibraryItem == null)+ if (_libraryItem == null){string id = QueryString["id"];if (!string.IsNullOrEmpty(id)){- _LibraryItem = Kernel.Instance.GetItemById(Guid.Parse(id)) as TBaseItemType;+ _libraryItem = Kernel.Instance.GetItemById(Guid.Parse(id)) as TBaseItemType;}}- return _LibraryItem;+ return _libraryItem;}}@@ -92,7 +92,7 @@ namespace MediaBrowser.Api.HttpHandlerspublic override Task<string> GetContentType(){- return Task.FromResult<string>(MimeTypes.GetMimeType("." + GetConversionOutputFormat()));+ return Task.FromResult(MimeTypes.GetMimeType("." + GetConversionOutputFormat()));}public override bool ShouldCompressResponse(string contentType)@@ -106,12 +106,10 @@ namespace MediaBrowser.Api.HttpHandlersif (!RequiresConversion()){- return new StaticFileHandler() { Path = LibraryItem.Path }.ProcessRequest(ctx);- }- else- {- return base.ProcessRequest(ctx);+ return new StaticFileHandler { Path = LibraryItem.Path }.ProcessRequest(ctx);}++ return base.ProcessRequest(ctx);}protected abstract string GetCommandLineArguments();@@ -173,7 +171,7 @@ namespace MediaBrowser.Api.HttpHandlersprocess.EnableRaisingEvents = true;- process.Exited += process_Exited;+ process.Exited += ProcessExited;try{@@ -203,7 +201,7 @@ namespace MediaBrowser.Api.HttpHandlers}}- void process_Exited(object sender, EventArgs e)+ void ProcessExited(object sender, EventArgs e){if (LogFileStream != null){diff --git a/MediaBrowser.Api/HttpHandlers/FavoriteStatusHandler.cs b/MediaBrowser.Api/HttpHandlers/FavoriteStatusHandler.csindex 4125b940f1..19c175d8b8 100644--- a/MediaBrowser.Api/HttpHandlers/FavoriteStatusHandler.cs+++ b/MediaBrowser.Api/HttpHandlers/FavoriteStatusHandler.cs@@ -1,7 +1,6 @@using MediaBrowser.Common.Net.Handlers;using MediaBrowser.Controller.Entities;using MediaBrowser.Model.DTO;-using MediaBrowser.Model.Entities;using System.ComponentModel.Composition;using System.Net;using System.Threading.Tasks;@@ -12,14 +11,14 @@ namespace MediaBrowser.Api.HttpHandlers/// Provides a handler to set user favorite status for an item/// </summary>[Export(typeof(BaseHandler))]- public class FavoriteStatusHandler : BaseSerializationHandler<DTOUserItemData>+ public class FavoriteStatusHandler : BaseSerializationHandler<DtoUserItemData>{public override bool HandlesRequest(HttpListenerRequest request){return ApiService.IsApiUrlMatch("FavoriteStatus", request);}- protected override Task<DTOUserItemData> GetObjectToSerialize()+ protected override Task<DtoUserItemData> GetObjectToSerialize(){// Get the itemBaseItem item = ApiService.GetItemById(QueryString["id"]);@@ -33,7 +32,7 @@ namespace MediaBrowser.Api.HttpHandlers// Set favorite statusdata.IsFavorite = QueryString["isfavorite"] == "1";- return Task.FromResult<DTOUserItemData>(ApiService.GetDTOUserItemData(data));+ return Task.FromResult(ApiService.GetDtoUserItemData(data));}}}\ No newline at end of filediff --git a/MediaBrowser.Api/HttpHandlers/GenresHandler.cs b/MediaBrowser.Api/HttpHandlers/GenresHandler.csindex 0ff48761ca..2694756dd3 100644--- a/MediaBrowser.Api/HttpHandlers/GenresHandler.cs+++ b/MediaBrowser.Api/HttpHandlers/GenresHandler.cs@@ -60,7 +60,7 @@ namespace MediaBrowser.Api.HttpHandlers}// Get the Genre objects- Genre[] entities = await Task.WhenAll<Genre>(data.Keys.Select(key => { return Kernel.Instance.ItemController.GetGenre(key); })).ConfigureAwait(false);+ Genre[] entities = await Task.WhenAll(data.Keys.Select(key => { return Kernel.Instance.ItemController.GetGenre(key); })).ConfigureAwait(false);// Convert to an array of IBNItemIBNItem[] items = new IBNItem[entities.Length];diff --git a/MediaBrowser.Api/HttpHandlers/ImageHandler.cs b/MediaBrowser.Api/HttpHandlers/ImageHandler.csindex c5949122fa..11246d4058 100644--- a/MediaBrowser.Api/HttpHandlers/ImageHandler.cs+++ b/MediaBrowser.Api/HttpHandlers/ImageHandler.cs@@ -21,15 +21,15 @@ namespace MediaBrowser.Api.HttpHandlersreturn ApiService.IsApiUrlMatch("image", request);}- private string _ImagePath = null;+ private string _imagePath;private async Task<string> GetImagePath(){- if (_ImagePath == null)+ if (_imagePath == null){- _ImagePath = await DiscoverImagePath();+ _imagePath = await DiscoverImagePath();}- return _ImagePath;+ return _imagePath;}private async Task<string> DiscoverImagePath()@@ -77,21 +77,21 @@ namespace MediaBrowser.Api.HttpHandlersreturn GetImagePathFromTypes(item, ImageType, index);}- private Stream _SourceStream = null;+ private Stream _sourceStream;private async Task<Stream> GetSourceStream(){await EnsureSourceStream().ConfigureAwait(false);- return _SourceStream;+ return _sourceStream;}- private bool _SourceStreamEnsured = false;+ private bool _sourceStreamEnsured;private async Task EnsureSourceStream(){- if (!_SourceStreamEnsured)+ if (!_sourceStreamEnsured){try{- _SourceStream = File.OpenRead(await GetImagePath().ConfigureAwait(false));+ _sourceStream = File.OpenRead(await GetImagePath().ConfigureAwait(false));}catch (FileNotFoundException ex){@@ -110,7 +110,7 @@ namespace MediaBrowser.Api.HttpHandlers}finally{- _SourceStreamEnsured = true;+ _sourceStreamEnsured = true;}}}@@ -248,26 +248,24 @@ namespace MediaBrowser.Api.HttpHandlers{return item.LogoImagePath;}- else if (imageType == ImageType.Backdrop)+ if (imageType == ImageType.Backdrop){return item.BackdropImagePaths.ElementAt(imageIndex);}- else if (imageType == ImageType.Banner)+ if (imageType == ImageType.Banner){return item.BannerImagePath;}- else if (imageType == ImageType.Art)+ if (imageType == ImageType.Art){return item.ArtImagePath;}- else if (imageType == ImageType.Thumbnail)+ if (imageType == ImageType.Thumbnail){return item.ThumbnailImagePath;}- else- {- return item.PrimaryImagePath;- }++ return item.PrimaryImagePath;}}}diff --git a/MediaBrowser.Api/HttpHandlers/ItemHandler.cs b/MediaBrowser.Api/HttpHandlers/ItemHandler.csindex 491f45446d..60b328d1a3 100644--- a/MediaBrowser.Api/HttpHandlers/ItemHandler.cs+++ b/MediaBrowser.Api/HttpHandlers/ItemHandler.cs@@ -11,14 +11,14 @@ namespace MediaBrowser.Api.HttpHandlers/// Provides a handler to retrieve a single item/// </summary>[Export(typeof(BaseHandler))]- public class ItemHandler : BaseSerializationHandler<DTOBaseItem>+ public class ItemHandler : BaseSerializationHandler<DtoBaseItem>{public override bool HandlesRequest(HttpListenerRequest request){return ApiService.IsApiUrlMatch("item", request);}- protected override Task<DTOBaseItem> GetObjectToSerialize()+ protected override Task<DtoBaseItem> GetObjectToSerialize(){User user = ApiService.GetUserById(QueryString["userid"], true);@@ -29,7 +29,7 @@ namespace MediaBrowser.Api.HttpHandlersreturn null;}- return ApiService.GetDTOBaseItem(item, user);+ return ApiService.GetDtoBaseItem(item, user);}}}diff --git a/MediaBrowser.Api/HttpHandlers/ItemListHandler.cs b/MediaBrowser.Api/HttpHandlers/ItemListHandler.csindex bce018d3ef..e4044b1d7b 100644--- a/MediaBrowser.Api/HttpHandlers/ItemListHandler.cs+++ b/MediaBrowser.Api/HttpHandlers/ItemListHandler.cs@@ -11,20 +11,20 @@ using System.Threading.Tasks;namespace MediaBrowser.Api.HttpHandlers{[Export(typeof(BaseHandler))]- public class ItemListHandler : BaseSerializationHandler<DTOBaseItem[]>+ public class ItemListHandler : BaseSerializationHandler<DtoBaseItem[]>{public override bool HandlesRequest(HttpListenerRequest request){return ApiService.IsApiUrlMatch("itemlist", request);}- protected override Task<DTOBaseItem[]> GetObjectToSerialize()+ protected override Task<DtoBaseItem[]> GetObjectToSerialize(){User user = ApiService.GetUserById(QueryString["userid"], true);- return Task.WhenAll<DTOBaseItem>(GetItemsToSerialize(user).Select(i =>+ return Task.WhenAll(GetItemsToSerialize(user).Select(i =>{- return ApiService.GetDTOBaseItem(i, user, includeChildren: false, includePeople: false);+ return ApiService.GetDtoBaseItem(i, user, includeChildren: false, includePeople: false);}));}@@ -36,31 +36,31 @@ namespace MediaBrowser.Api.HttpHandlers{return parent.GetInProgressItems(user);}- else if (ListType.Equals("recentlyaddeditems", StringComparison.OrdinalIgnoreCase))+ if (ListType.Equals("recentlyaddeditems", StringComparison.OrdinalIgnoreCase)){return parent.GetRecentlyAddedItems(user);}- else if (ListType.Equals("recentlyaddedunplayeditems", StringComparison.OrdinalIgnoreCase))+ if (ListType.Equals("recentlyaddedunplayeditems", StringComparison.OrdinalIgnoreCase)){return parent.GetRecentlyAddedUnplayedItems(user);}- else if (ListType.Equals("itemswithgenre", StringComparison.OrdinalIgnoreCase))+ if (ListType.Equals("itemswithgenre", StringComparison.OrdinalIgnoreCase)){return parent.GetItemsWithGenre(QueryString["name"], user);}- else if (ListType.Equals("itemswithyear", StringComparison.OrdinalIgnoreCase))+ if (ListType.Equals("itemswithyear", StringComparison.OrdinalIgnoreCase)){return parent.GetItemsWithYear(int.Parse(QueryString["year"]), user);}- else if (ListType.Equals("itemswithstudio", StringComparison.OrdinalIgnoreCase))+ if (ListType.Equals("itemswithstudio", StringComparison.OrdinalIgnoreCase)){return parent.GetItemsWithStudio(QueryString["name"], user);}- else if (ListType.Equals("itemswithperson", StringComparison.OrdinalIgnoreCase))+ if (ListType.Equals("itemswithperson", StringComparison.OrdinalIgnoreCase)){return parent.GetItemsWithPerson(QueryString["name"], null, user);}- else if (ListType.Equals("favorites", StringComparison.OrdinalIgnoreCase))+ if (ListType.Equals("favorites", StringComparison.OrdinalIgnoreCase)){return parent.GetFavoriteItems(user);}diff --git a/MediaBrowser.Api/HttpHandlers/MovieSpecialFeaturesHandler.cs b/MediaBrowser.Api/HttpHandlers/MovieSpecialFeaturesHandler.csindex 63426be47d..cfd75c8cfa 100644--- a/MediaBrowser.Api/HttpHandlers/MovieSpecialFeaturesHandler.cs+++ b/MediaBrowser.Api/HttpHandlers/MovieSpecialFeaturesHandler.cs@@ -13,14 +13,14 @@ namespace MediaBrowser.Api.HttpHandlers/// This handler retrieves special features for movies/// </summary>[Export(typeof(BaseHandler))]- public class MovieSpecialFeaturesHandler : BaseSerializationHandler<DTOBaseItem[]>+ public class MovieSpecialFeaturesHandler : BaseSerializationHandler<DtoBaseItem[]>{public override bool HandlesRequest(HttpListenerRequest request){return ApiService.IsApiUrlMatch("MovieSpecialFeatures", request);}- protected override Task<DTOBaseItem[]> GetObjectToSerialize()+ protected override Task<DtoBaseItem[]> GetObjectToSerialize(){User user = ApiService.GetUserById(QueryString["userid"], true);@@ -29,12 +29,12 @@ namespace MediaBrowser.Api.HttpHandlers// If noneif (movie.SpecialFeatures == null){- return Task.FromResult<DTOBaseItem[]>(new DTOBaseItem[] { });+ return Task.FromResult(new DtoBaseItem[] { });}- return Task.WhenAll<DTOBaseItem>(movie.SpecialFeatures.Select(i =>+ return Task.WhenAll(movie.SpecialFeatures.Select(i =>{- return ApiService.GetDTOBaseItem(i, user, includeChildren: false, includePeople: true);+ return ApiService.GetDtoBaseItem(i, user, includeChildren: false);}));}diff --git a/MediaBrowser.Api/HttpHandlers/PlayedStatusHandler.cs b/MediaBrowser.Api/HttpHandlers/PlayedStatusHandler.csindex 4fe790c801..c010bcb023 100644--- a/MediaBrowser.Api/HttpHandlers/PlayedStatusHandler.cs+++ b/MediaBrowser.Api/HttpHandlers/PlayedStatusHandler.cs@@ -1,7 +1,6 @@using MediaBrowser.Common.Net.Handlers;using MediaBrowser.Controller.Entities;using MediaBrowser.Model.DTO;-using MediaBrowser.Model.Entities;using System.ComponentModel.Composition;using System.Net;using System.Threading.Tasks;@@ -12,14 +11,14 @@ namespace MediaBrowser.Api.HttpHandlers/// Provides a handler to set played status for an item/// </summary>[Export(typeof(BaseHandler))]- public class PlayedStatusHandler : BaseSerializationHandler<DTOUserItemData>+ public class PlayedStatusHandler : BaseSerializationHandler<DtoUserItemData>{public override bool HandlesRequest(HttpListenerRequest request){return ApiService.IsApiUrlMatch("PlayedStatus", request);}- protected override Task<DTOUserItemData> GetObjectToSerialize()+ protected override Task<DtoUserItemData> GetObjectToSerialize(){// Get the itemBaseItem item = ApiService.GetItemById(QueryString["id"]);@@ -33,7 +32,7 @@ namespace MediaBrowser.Api.HttpHandlersUserItemData data = item.GetUserData(user, true);- return Task.FromResult<DTOUserItemData>(ApiService.GetDTOUserItemData(data));+ return Task.FromResult(ApiService.GetDtoUserItemData(data));}}}\ No newline at end of filediff --git a/MediaBrowser.Api/HttpHandlers/PluginAssemblyHandler.cs b/MediaBrowser.Api/HttpHandlers/PluginAssemblyHandler.csindex 07e6115a59..88161c1140 100644--- a/MediaBrowser.Api/HttpHandlers/PluginAssemblyHandler.cs+++ b/MediaBrowser.Api/HttpHandlers/PluginAssemblyHandler.cs@@ -32,7 +32,7 @@ namespace MediaBrowser.Api.HttpHandlersstring path = Path.Combine(Kernel.Instance.ApplicationPaths.PluginsPath, filename);- return new StaticFileHandler() { Path = path }.ProcessRequest(ctx);+ return new StaticFileHandler { Path = path }.ProcessRequest(ctx);}}}diff --git a/MediaBrowser.Api/HttpHandlers/PluginConfigurationHandler.cs b/MediaBrowser.Api/HttpHandlers/PluginConfigurationHandler.csindex 6dafd41707..95af9a3442 100644--- a/MediaBrowser.Api/HttpHandlers/PluginConfigurationHandler.cs+++ b/MediaBrowser.Api/HttpHandlers/PluginConfigurationHandler.cs@@ -18,25 +18,25 @@ namespace MediaBrowser.Api.HttpHandlersreturn ApiService.IsApiUrlMatch("pluginconfiguration", request);}- private BasePlugin _Plugin = null;+ private BasePlugin _plugin;private BasePlugin Plugin{get{- if (_Plugin == null)+ if (_plugin == null){string name = QueryString["assemblyfilename"];- _Plugin = Kernel.Instance.Plugins.First(p => p.AssemblyFileName.Equals(name, StringComparison.OrdinalIgnoreCase));+ _plugin = Kernel.Instance.Plugins.First(p => p.AssemblyFileName.Equals(name, StringComparison.OrdinalIgnoreCase));}- return _Plugin;+ return _plugin;}}protected override Task<BasePluginConfiguration> GetObjectToSerialize(){- return Task.FromResult<BasePluginConfiguration>(Plugin.Configuration);+ return Task.FromResult(Plugin.Configuration);}public override TimeSpan CacheDurationdiff --git a/MediaBrowser.Api/HttpHandlers/PluginsHandler.cs b/MediaBrowser.Api/HttpHandlers/PluginsHandler.csindex e90f322391..e9de0c476a 100644--- a/MediaBrowser.Api/HttpHandlers/PluginsHandler.cs+++ b/MediaBrowser.Api/HttpHandlers/PluginsHandler.cs@@ -24,7 +24,7 @@ namespace MediaBrowser.Api.HttpHandlers{var plugins = Kernel.Instance.Plugins.Select(p =>{- return new PluginInfo()+ return new PluginInfo{Name = p.Name,Enabled = p.Enabled,@@ -35,7 +35,7 @@ namespace MediaBrowser.Api.HttpHandlers};});- return Task.FromResult<IEnumerable<PluginInfo>>(plugins);+ return Task.FromResult(plugins);}}}diff --git a/MediaBrowser.Api/HttpHandlers/ServerConfigurationHandler.cs b/MediaBrowser.Api/HttpHandlers/ServerConfigurationHandler.csindex bbda31dc61..64ba44ec2f 100644--- a/MediaBrowser.Api/HttpHandlers/ServerConfigurationHandler.cs+++ b/MediaBrowser.Api/HttpHandlers/ServerConfigurationHandler.cs@@ -19,7 +19,7 @@ namespace MediaBrowser.Api.HttpHandlersprotected override Task<ServerConfiguration> GetObjectToSerialize(){- return Task.FromResult<ServerConfiguration>(Kernel.Instance.Configuration);+ return Task.FromResult(Kernel.Instance.Configuration);}public override TimeSpan CacheDurationdiff --git a/MediaBrowser.Api/HttpHandlers/StudiosHandler.cs b/MediaBrowser.Api/HttpHandlers/StudiosHandler.csindex f80bed0896..86aa7c9c94 100644--- a/MediaBrowser.Api/HttpHandlers/StudiosHandler.cs+++ b/MediaBrowser.Api/HttpHandlers/StudiosHandler.cs@@ -60,7 +60,7 @@ namespace MediaBrowser.Api.HttpHandlers}// Get the Studio objects- Studio[] entities = await Task.WhenAll<Studio>(data.Keys.Select(key => { return Kernel.Instance.ItemController.GetStudio(key); })).ConfigureAwait(false);+ Studio[] entities = await Task.WhenAll(data.Keys.Select(key => { return Kernel.Instance.ItemController.GetStudio(key); })).ConfigureAwait(false);// Convert to an array of IBNItemIBNItem[] items = new IBNItem[entities.Length];diff --git a/MediaBrowser.Api/HttpHandlers/UserHandler.cs b/MediaBrowser.Api/HttpHandlers/UserHandler.csindex 5ccf3bb619..8b9e657661 100644--- a/MediaBrowser.Api/HttpHandlers/UserHandler.cs+++ b/MediaBrowser.Api/HttpHandlers/UserHandler.cs@@ -8,22 +8,22 @@ using System.Threading.Tasks;namespace MediaBrowser.Api.HttpHandlers{[Export(typeof(BaseHandler))]- class UserHandler : BaseSerializationHandler<DTOUser>+ class UserHandler : BaseSerializationHandler<DtoUser>{public override bool HandlesRequest(HttpListenerRequest request){return ApiService.IsApiUrlMatch("user", request);}-- protected override Task<DTOUser> GetObjectToSerialize()++ protected override Task<DtoUser> GetObjectToSerialize(){string id = QueryString["id"];User user = string.IsNullOrEmpty(id) ? ApiService.GetDefaultUser(false) : ApiService.GetUserById(id, false); ;- DTOUser dto = ApiService.GetDTOUser(user);+ DtoUser dto = ApiService.GetDtoUser(user);- return Task.FromResult<DTOUser>(dto);+ return Task.FromResult(dto);}}}diff --git a/MediaBrowser.Api/HttpHandlers/UserItemRatingHandler.cs b/MediaBrowser.Api/HttpHandlers/UserItemRatingHandler.csindex d040414088..aed0804b6d 100644--- a/MediaBrowser.Api/HttpHandlers/UserItemRatingHandler.cs+++ b/MediaBrowser.Api/HttpHandlers/UserItemRatingHandler.cs@@ -1,7 +1,6 @@using MediaBrowser.Common.Net.Handlers;using MediaBrowser.Controller.Entities;using MediaBrowser.Model.DTO;-using MediaBrowser.Model.Entities;using System.ComponentModel.Composition;using System.Net;using System.Threading.Tasks;@@ -12,14 +11,14 @@ namespace MediaBrowser.Api.HttpHandlers/// Provides a handler to set a user's rating for an item/// </summary>[Export(typeof(BaseHandler))]- public class UserItemRatingHandler : BaseSerializationHandler<DTOUserItemData>+ public class UserItemRatingHandler : BaseSerializationHandler<DtoUserItemData>{public override bool HandlesRequest(HttpListenerRequest request){return ApiService.IsApiUrlMatch("UserItemRating", request);}- protected override Task<DTOUserItemData> GetObjectToSerialize()+ protected override Task<DtoUserItemData> GetObjectToSerialize(){// Get the itemBaseItem item = ApiService.GetItemById(QueryString["id"]);@@ -41,7 +40,7 @@ namespace MediaBrowser.Api.HttpHandlersdata.Likes = QueryString["likes"] == "1";}- return Task.FromResult<DTOUserItemData>(ApiService.GetDTOUserItemData(data));+ return Task.FromResult(ApiService.GetDtoUserItemData(data));}}}\ No newline at end of filediff --git a/MediaBrowser.Api/HttpHandlers/UsersHandler.cs b/MediaBrowser.Api/HttpHandlers/UsersHandler.csindex 1451216bc6..3fc3a7d585 100644--- a/MediaBrowser.Api/HttpHandlers/UsersHandler.cs+++ b/MediaBrowser.Api/HttpHandlers/UsersHandler.cs@@ -10,16 +10,16 @@ using System.Threading.Tasks;namespace MediaBrowser.Api.HttpHandlers{[Export(typeof(BaseHandler))]- class UsersHandler : BaseSerializationHandler<IEnumerable<DTOUser>>+ class UsersHandler : BaseSerializationHandler<IEnumerable<DtoUser>>{public override bool HandlesRequest(HttpListenerRequest request){return ApiService.IsApiUrlMatch("users", request);}- protected override Task<IEnumerable<DTOUser>> GetObjectToSerialize()+ protected override Task<IEnumerable<DtoUser>> GetObjectToSerialize(){- return Task.FromResult<IEnumerable<DTOUser>>(Kernel.Instance.Users.Select(u => ApiService.GetDTOUser(u)));+ return Task.FromResult(Kernel.Instance.Users.Select(u => ApiService.GetDtoUser(u)));}}}diff --git a/MediaBrowser.Api/HttpHandlers/VideoHandler.cs b/MediaBrowser.Api/HttpHandlers/VideoHandler.csindex 4f8621ce7e..5e61127c6c 100644--- a/MediaBrowser.Api/HttpHandlers/VideoHandler.cs+++ b/MediaBrowser.Api/HttpHandlers/VideoHandler.cs@@ -34,7 +34,7 @@ namespace MediaBrowser.Api.HttpHandlers// mp4, 3gp, mov - muxer does not support non-seekable output// avi, mov, mkv, m4v - can't stream these when encoding. the player will try to download them completely before starting playback.// wmv - can't seem to figure out the output format name- return new VideoOutputFormats[] { VideoOutputFormats.Mp4, VideoOutputFormats.ThreeGP, VideoOutputFormats.M4v, VideoOutputFormats.Mkv, VideoOutputFormats.Avi, VideoOutputFormats.Mov, VideoOutputFormats.Wmv };+ return new VideoOutputFormats[] { VideoOutputFormats.Mp4, VideoOutputFormats.ThreeGp, VideoOutputFormats.M4V, VideoOutputFormats.Mkv, VideoOutputFormats.Avi, VideoOutputFormats.Mov, VideoOutputFormats.Wmv };}}@@ -87,11 +87,11 @@ namespace MediaBrowser.Api.HttpHandlers{return "matroska";}- else if (outputFormat == VideoOutputFormats.Ts)+ if (outputFormat == VideoOutputFormats.Ts){return "mpegts";}- else if (outputFormat == VideoOutputFormats.Ogv)+ if (outputFormat == VideoOutputFormats.Ogv){return "ogg";}@@ -104,8 +104,6 @@ namespace MediaBrowser.Api.HttpHandlers/// </summary>protected override string GetCommandLineArguments(){- List<string> audioTranscodeParams = new List<string>();-VideoOutputFormats outputFormat = GetConversionOutputFormat();return string.Format("-i \"{0}\" -threads 0 {1} {2} -f {3} -",@@ -195,15 +193,15 @@ namespace MediaBrowser.Api.HttpHandlers// Per webm specification, it must be vpxreturn "libvpx";}- else if (outputFormat == VideoOutputFormats.Asf)+ if (outputFormat == VideoOutputFormats.Asf){return "wmv2";}- else if (outputFormat == VideoOutputFormats.Wmv)+ if (outputFormat == VideoOutputFormats.Wmv){return "wmv2";}- else if (outputFormat == VideoOutputFormats.Ogv)+ if (outputFormat == VideoOutputFormats.Ogv){return "libtheora";}@@ -223,21 +221,21 @@ namespace MediaBrowser.Api.HttpHandlersprivate string GetAudioCodec(AudioStream audioStream, VideoOutputFormats outputFormat){// Some output containers require specific codecs-+if (outputFormat == VideoOutputFormats.Webm){// Per webm specification, it must be vorbisreturn "libvorbis";}- else if (outputFormat == VideoOutputFormats.Asf)+ if (outputFormat == VideoOutputFormats.Asf){return "wmav2";}- else if (outputFormat == VideoOutputFormats.Wmv)+ if (outputFormat == VideoOutputFormats.Wmv){return "wmav2";}- else if (outputFormat == VideoOutputFormats.Ogv)+ if (outputFormat == VideoOutputFormats.Ogv){return "libvorbis";}@@ -263,7 +261,7 @@ namespace MediaBrowser.Api.HttpHandlers// libvo_aacenc currently only supports two channel outputreturn 2;}- else if (audioCodec.Equals("wmav2"))+ if (audioCodec.Equals("wmav2")){// wmav2 currently only supports two channel outputreturn 2;diff --git a/MediaBrowser.Api/HttpHandlers/YearsHandler.cs b/MediaBrowser.Api/HttpHandlers/YearsHandler.csindex c33464c4cc..a8c97294c4 100644--- a/MediaBrowser.Api/HttpHandlers/YearsHandler.cs+++ b/MediaBrowser.Api/HttpHandlers/YearsHandler.cs@@ -57,7 +57,7 @@ namespace MediaBrowser.Api.HttpHandlers}// Get the Year objects- Year[] entities = await Task.WhenAll<Year>(data.Keys.Select(key => { return Kernel.Instance.ItemController.GetYear(key); })).ConfigureAwait(false);+ Year[] entities = await Task.WhenAll(data.Keys.Select(key => { return Kernel.Instance.ItemController.GetYear(key); })).ConfigureAwait(false);// Convert to an array of IBNItemIBNItem[] items = new IBNItem[entities.Length];diff --git a/MediaBrowser.Api/Properties/AssemblyInfo.cs b/MediaBrowser.Api/Properties/AssemblyInfo.csindex bd747ea7da..c92346bac1 100644--- a/MediaBrowser.Api/Properties/AssemblyInfo.cs+++ b/MediaBrowser.Api/Properties/AssemblyInfo.cs@@ -1,5 +1,4 @@using System.Reflection;-using System.Runtime.CompilerServices;using System.Runtime.InteropServices;// General Information about an assembly is controlled through the followingdiff --git a/MediaBrowser.ApiInteraction.Metro/DataSerializer.cs b/MediaBrowser.ApiInteraction.Metro/DataSerializer.csindex d63e3f0213..92e3f7c2b7 100644--- a/MediaBrowser.ApiInteraction.Metro/DataSerializer.cs+++ b/MediaBrowser.ApiInteraction.Metro/DataSerializer.cs@@ -12,7 +12,7 @@ namespace MediaBrowser.ApiInteraction/// This means that this class can currently only handle types within the Model project./// If we need to, we can always add a param indicating whether or not the model serializer should be used./// </summary>- private static ProtobufModelSerializer ProtobufModelSerializer = new ProtobufModelSerializer();+ private static readonly ProtobufModelSerializer ProtobufModelSerializer = new ProtobufModelSerializer();public static T DeserializeFromStream<T>(Stream stream, SerializationFormats format)where T : classdiff --git a/MediaBrowser.ApiInteraction.Portable/ApiClient.cs b/MediaBrowser.ApiInteraction.Portable/ApiClient.csdeleted file mode 100644index b41572cd36..0000000000--- a/MediaBrowser.ApiInteraction.Portable/ApiClient.cs+++ /dev/null@@ -1,585 +0,0 @@-using MediaBrowser.Model.Authentication;-using MediaBrowser.Model.Configuration;-using MediaBrowser.Model.DTO;-using MediaBrowser.Model.Weather;-using System;-using System.Collections.Generic;-using System.IO;-using System.Linq;-using System.Net;-using System.Text;--namespace MediaBrowser.ApiInteraction.Portable-{- public class ApiClient : BaseApiClient- {- private HttpWebRequest GetNewRequest(string url)- {- return HttpWebRequest.CreateHttp(url);- }-- /// <summary>- /// Gets an image stream based on a url- /// </summary>- public void GetImageStreamAsync(string url, Action<Stream> callback)- {- GetStreamAsync(url, callback);- }-- /// <summary>- /// Gets an image stream based on a url- /// </summary>- private void GetStreamAsync(string url, Action<Stream> callback)- {- HttpWebRequest request = GetNewRequest(url);-- request.BeginGetResponse(new AsyncCallback(result =>- {- using (WebResponse response = (result.AsyncState as HttpWebRequest).EndGetResponse(result))- {- Stream stream = response.GetResponseStream();- callback(stream);- }-- }), request);- }-- /// <summary>- /// Gets a BaseItem- /// </summary>- public void GetItemAsync(Guid id, Guid userId, Action<DTOBaseItem> callback)- {- string url = ApiUrl + "/item?userId=" + userId.ToString();-- if (id != Guid.Empty)- {- url += "&id=" + id.ToString();- }-- GetDataAsync(url, callback);- }-- /// <summary>- /// Gets all users- /// </summary>- public void GetAllUsersAsync(Action<DTOUser[]> callback)- {- string url = ApiUrl + "/users";-- GetDataAsync(url, callback);- }-- /// <summary>- /// Gets all Genres- /// </summary>- public void GetAllGenresAsync(Guid userId, Action<IBNItem[]> callback)- {- string url = ApiUrl + "/genres?userId=" + userId.ToString();-- GetDataAsync(url, callback);- }-- /// <summary>- /// Gets in-progress items- /// </summary>- /// <param name="userId">The user id.</param>- /// <param name="folderId">(Optional) Specify a folder Id to localize the search to a specific folder.</param>- public void GetInProgressItemsItemsAsync(Guid userId, Action<DTOBaseItem[]> callback, Guid? folderId = null)- {- string url = ApiUrl + "/itemlist?listtype=inprogressitems&userId=" + userId.ToString();-- if (folderId.HasValue)- {- url += "&id=" + folderId.ToString();- }-- GetDataAsync(url, callback);- }-- /// <summary>- /// Gets recently added items- /// </summary>- /// <param name="userId">The user id.</param>- /// <param name="folderId">(Optional) Specify a folder Id to localize the search to a specific folder.</param>- public void GetRecentlyAddedItemsAsync(Guid userId, Action<DTOBaseItem[]> callback, Guid? folderId = null)- {- string url = ApiUrl + "/itemlist?listtype=recentlyaddeditems&userId=" + userId.ToString();-- if (folderId.HasValue)- {- url += "&id=" + folderId.ToString();- }-- GetDataAsync(url, callback);- }-- /// <summary>- /// Gets favorite items- /// </summary>- /// <param name="userId">The user id.</param>- /// <param name="folderId">(Optional) Specify a folder Id to localize the search to a specific folder.</param>- public void GetFavoriteItemsAsync(Guid userId, Action<DTOBaseItem[]> callback, Guid? folderId = null)- {- string url = ApiUrl + "/itemlist?listtype=favorites&userId=" + userId.ToString();-- if (folderId.HasValue)- {- url += "&id=" + folderId.ToString();- }-- GetDataAsync(url, callback);- }-- /// <summary>- /// Gets recently added items that are unplayed.- /// </summary>- /// <param name="userId">The user id.</param>- /// <param name="folderId">(Optional) Specify a folder Id to localize the search to a specific folder.</param>- public void GetRecentlyAddedUnplayedItemsAsync(Guid userId, Action<DTOBaseItem[]> callback, Guid? folderId = null)- {- string url = ApiUrl + "/itemlist?listtype=recentlyaddedunplayeditems&userId=" + userId.ToString();-- if (folderId.HasValue)- {- url += "&id=" + folderId.ToString();- }-- GetDataAsync(url, callback);- }-- /// <summary>- /// Gets all Years- /// </summary>- public void GetAllYearsAsync(Guid userId, Action<IBNItem[]> callback)- {- string url = ApiUrl + "/years?userId=" + userId.ToString();-- GetDataAsync(url, callback);- }-- /// <summary>- /// Gets all items that contain a given Year- /// </summary>- public void GetItemsWithYearAsync(string name, Guid userId, Action<DTOBaseItem[]> callback, Guid? folderId = null)- {- string url = ApiUrl + "/itemlist?listtype=itemswithyear&userId=" + userId.ToString() + "&name=" + name;-- if (folderId.HasValue)- {- url += "&id=" + folderId.ToString();- }-- GetDataAsync(url, callback);- }-- /// <summary>- /// Gets all items that contain a given Genre- /// </summary>- public void GetItemsWithGenreAsync(string name, Guid userId, Action<DTOBaseItem[]> callback, Guid? folderId = null)- {- string url = ApiUrl + "/itemlist?listtype=itemswithgenre&userId=" + userId.ToString() + "&name=" + name;-- if (folderId.HasValue)- {- url += "&id=" + folderId.ToString();- }-- GetDataAsync(url, callback);- }-- /// <summary>- /// Gets all items that contain a given Person- /// </summary>- public void GetItemsWithPersonAsync(string name, Guid userId, Action<DTOBaseItem[]> callback, Guid? folderId = null)- {- string url = ApiUrl + "/itemlist?listtype=itemswithperson&userId=" + userId.ToString() + "&name=" + name;-- if (folderId.HasValue)- {- url += "&id=" + folderId.ToString();- }-- GetDataAsync(url, callback);- }-- /// <summary>- /// Gets all items that contain a given Person- /// </summary>- public void GetItemsWithPersonAsync(string name, string personType, Guid userId, Action<DTOBaseItem[]> callback, Guid? folderId = null)- {- string url = ApiUrl + "/itemlist?listtype=itemswithperson&userId=" + userId.ToString() + "&name=" + name;-- if (folderId.HasValue)- {- url += "&id=" + folderId.ToString();- }-- url += "&persontype=" + personType;-- GetDataAsync(url, callback);- }-- /// <summary>- /// Gets all studious- /// </summary>- public void GetAllStudiosAsync(Guid userId, Action<IBNItem[]> callback)- {- string url = ApiUrl + "/studios?userId=" + userId.ToString();-- GetDataAsync(url, callback);- }-- /// <summary>- /// Gets all items that contain a given Studio- /// </summary>- public void GetItemsWithStudioAsync(string name, Guid userId, Action<DTOBaseItem[]> callback, Guid? folderId = null)- {- string url = ApiUrl + "/itemlist?listtype=itemswithstudio&userId=" + userId.ToString() + "&name=" + name;-- if (folderId.HasValue)- {- url += "&id=" + folderId.ToString();- }-- GetDataAsync(url, callback);- }-- /// <summary>- /// Gets a studio- /// </summary>- public void GetStudioAsync(Guid userId, string name, Action<IBNItem> callback)- {- string url = ApiUrl + "/studio?userId=" + userId.ToString() + "&name=" + name;-- GetDataAsync(url, callback);- }-- /// <summary>- /// Gets a genre- /// </summary>- public void GetGenreAsync(Guid userId, string name, Action<IBNItem> callback)- {- string url = ApiUrl + "/genre?userId=" + userId.ToString() + "&name=" + name;-- GetDataAsync(url, callback);- }-- /// <summary>- /// Gets a person- /// </summary>- public void GetPersonAsync(Guid userId, string name, Action<IBNItem> callback)- {- string url = ApiUrl + "/person?userId=" + userId.ToString() + "&name=" + name;-- GetDataAsync(url, callback);- }-- /// <summary>- /// Gets a year- /// </summary>- public void GetYearAsync(Guid userId, int year, Action<IBNItem> callback)- {- string url = ApiUrl + "/year?userId=" + userId.ToString() + "&year=" + year;-- GetDataAsync(url, callback);- }-- /// <summary>- /// Gets a list of plugins installed on the server- /// </summary>- public void GetInstalledPluginsAsync(Action<PluginInfo[]> callback)- {- string url = ApiUrl + "/plugins";-- GetDataAsync(url, callback);- }-- /// <summary>- /// Gets a list of plugins installed on the server- /// </summary>- public void GetPluginAssemblyAsync(PluginInfo plugin, Action<Stream> callback)- {- string url = ApiUrl + "/pluginassembly?assemblyfilename=" + plugin.AssemblyFileName;-- GetStreamAsync(url, callback);- }-- /// <summary>- /// Gets the current server configuration- /// </summary>- public void GetServerConfigurationAsync(Action<ServerConfiguration> callback)- {- string url = ApiUrl + "/ServerConfiguration";-- GetDataAsync(url, callback);- }-- /// <summary>- /// Gets weather information for the default location as set in configuration- /// </summary>- public void GetPluginConfigurationAsync(PluginInfo plugin, Type configurationType, Action<object> callback)- {- string url = ApiUrl + "/PluginConfiguration?assemblyfilename=" + plugin.AssemblyFileName;-- // At the moment this can't be retrieved in protobuf format- SerializationFormats format = DataSerializer.CanDeSerializeJsv ? SerializationFormats.Jsv : SerializationFormats.Json;-- GetDataAsync(url, callback, configurationType, format);- }-- /// <summary>- /// Gets the default user- /// </summary>- public void GetDefaultUserAsync(Action<DTOUser> callback)- {- string url = ApiUrl + "/user";-- GetDataAsync(url, callback);- }-- /// <summary>- /// Gets a user by id- /// </summary>- public void GetUserAsync(Guid id, Action<DTOUser> callback)- {- string url = ApiUrl + "/user?id=" + id.ToString();-- GetDataAsync(url, callback);- }-- /// <summary>- /// Gets weather information for the default location as set in configuration- /// </summary>- public void GetWeatherInfoAsync(Action<WeatherInfo> callback)- {- string url = ApiUrl + "/weather";-- GetDataAsync(url, callback);- }-- /// <summary>- /// Gets weather information for a specific zip code- /// </summary>- public void GetWeatherInfoAsync(string zipCode, Action<WeatherInfo> callback)- {- string url = ApiUrl + "/weather?zipcode=" + zipCode;-- GetDataAsync(url, callback);- }-- /// <summary>- /// Gets special features for a Movie- /// </summary>- public void GetMovieSpecialFeaturesAsync(Guid itemId, Guid userId, Action<DTOBaseItem[]> callback)- {- string url = ApiUrl + "/MovieSpecialFeatures?id=" + itemId;- url += "&userid=" + userId;-- GetDataAsync(url, callback);- }-- /// <summary>- /// Authenticates a user and returns the result- /// </summary>- public void AuthenticateUserAsync(Guid userId, string password, Action<AuthenticationResult> callback)- {- string url = ApiUrl + "/UserAuthentication?dataformat=" + SerializationFormat.ToString();-- Dictionary<string, string> formValues = new Dictionary<string, string>();-- formValues["userid"] = userId.ToString();-- if (!string.IsNullOrEmpty(password))- {- formValues["password"] = password;- }-- PostDataAsync(url, formValues, callback, SerializationFormat);- }-- /// <summary>- /// Updates a user's favorite status for an item and returns the updated UserItemData object.- /// </summary>- public void UpdateFavoriteStatusAsync(Guid itemId, Guid userId, bool isFavorite, Action<DTOUserItemData> callback)- {- string url = ApiUrl + "/favoritestatus?id=" + itemId;-- url += "&userid=" + userId;- url += "&isfavorite=" + (isFavorite ? "1" : "0");-- GetDataAsync(url, callback);- }-- /// <summary>- /// Updates played status for an item- /// </summary>- public void UpdatePlayedStatusAsync(Guid itemId, Guid userId, bool wasPlayed, Action<DTOUserItemData> callback)- {- string url = ApiUrl + "/PlayedStatus?id=" + itemId;-- url += "&userid=" + userId;- url += "&played=" + (wasPlayed ? "1" : "0");-- GetDataAsync(url, callback);- }-- /// <summary>- /// Clears a user's rating for an item- /// </summary>- public void ClearUserItemRatingAsync(Guid itemId, Guid userId, Action<DTOUserItemData> callback)- {- string url = ApiUrl + "/UserItemRating?id=" + itemId;-- url += "&userid=" + userId;- url += "&clear=1";-- GetDataAsync(url, callback);- }-- /// <summary>- /// Updates a user's rating for an item, based on likes or dislikes- /// </summary>- public void UpdateUserItemRatingAsync(Guid itemId, Guid userId, bool likes, Action<DTOUserItemData> callback)- {- string url = ApiUrl + "/UserItemRating?id=" + itemId;-- url += "&userid=" + userId;- url += "&likes=" + (likes ? "1" : "0");-- GetDataAsync(url, callback);- }-- /// <summary>- /// Performs a GET request, and deserializes the response stream to an object of Type T- /// </summary>- private void GetDataAsync<T>(string url, Action<T> callback)- where T : class- {- GetDataAsync<T>(url, callback, SerializationFormat);- }-- /// <summary>- /// Performs a GET request, and deserializes the response stream to an object of Type T- /// </summary>- private void GetDataAsync<T>(string url, Action<T> callback, SerializationFormats serializationFormat)- where T : class- {- if (url.IndexOf('?') == -1)- {- url += "?dataformat=" + serializationFormat.ToString();- }- else- {- url += "&dataformat=" + serializationFormat.ToString();- }-- HttpWebRequest request = GetNewRequest(url);-- request.BeginGetResponse(new AsyncCallback(result =>- {- T value;-- using (WebResponse response = (result.AsyncState as HttpWebRequest).EndGetResponse(result))- {- using (Stream stream = response.GetResponseStream())- {- value = DeserializeFromStream<T>(stream);- }- }-- callback(value);-- }), request);- }-- /// <summary>- /// Performs a GET request, and deserializes the response stream to an object of Type T- /// </summary>- private void GetDataAsync(string url, Action<object> callback, Type type, SerializationFormats serializationFormat)- {- if (url.IndexOf('?') == -1)- {- url += "?dataformat=" + serializationFormat.ToString();- }- else- {- url += "&dataformat=" + serializationFormat.ToString();- }-- HttpWebRequest request = GetNewRequest(url);-- request.BeginGetResponse(new AsyncCallback(result =>- {- object value;-- using (WebResponse response = (result.AsyncState as HttpWebRequest).EndGetResponse(result))- {- using (Stream stream = response.GetResponseStream())- {- value = DataSerializer.DeserializeFromStream(stream, serializationFormat, type);- }- }-- callback(value);-- }), request);- }-- /// <summary>- /// Performs a POST request, and deserializes the response stream to an object of Type T- /// </summary>- private void PostDataAsync<T>(string url, Dictionary<string, string> formValues, Action<T> callback, SerializationFormats serializationFormat)- where T : class- {- if (url.IndexOf('?') == -1)- {- url += "?dataformat=" + serializationFormat.ToString();- }- else- {- url += "&dataformat=" + serializationFormat.ToString();- }-- HttpWebRequest request = GetNewRequest(url);-- request.Method = "POST";- request.ContentType = "application/x-www-form-urlencoded";-- // Begin getting request stream- request.BeginGetRequestStream(new AsyncCallback(beginGetRequestStreamResult =>- {- // Once we have the request stream, write the post data- using (Stream requestStream = request.EndGetRequestStream(beginGetRequestStreamResult))- {- // Construct the body- string postBody = string.Join("&", formValues.Keys.Select(s => string.Format("{0}={1}", s, formValues[s])).ToArray());-- // Convert the string into a byte array.- byte[] byteArray = Encoding.UTF8.GetBytes(postBody);-- // Write to the request stream.- requestStream.Write(byteArray, 0, byteArray.Length);- }-- // Begin getting response stream- request.BeginGetResponse(new AsyncCallback(result =>- {- // Once we have it, deserialize the data and execute the callback- T value;-- using (WebResponse response = request.EndGetResponse(result))- {- using (Stream responseStream = response.GetResponseStream())- {- value = DeserializeFromStream<T>(responseStream);- }- }-- callback(value);-- }), null);-- }), null);- }- }-}diff --git a/MediaBrowser.ApiInteraction.Portable/MediaBrowser.ApiInteraction.Portable.csproj b/MediaBrowser.ApiInteraction.Portable/MediaBrowser.ApiInteraction.Portable.csprojdeleted file mode 100644index b46505e9db..0000000000--- a/MediaBrowser.ApiInteraction.Portable/MediaBrowser.ApiInteraction.Portable.csproj+++ /dev/null@@ -1,72 +0,0 @@-<?xml version="1.0" encoding="utf-8"?>-<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">- <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />- <PropertyGroup>- <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>- <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>- <ProjectGuid>{756B93D2-5FFA-4B8D-BDCA-127476F1E6FB}</ProjectGuid>- <OutputType>Library</OutputType>- <AppDesignerFolder>Properties</AppDesignerFolder>- <RootNamespace>MediaBrowser.ApiInteraction.Portable</RootNamespace>- <AssemblyName>MediaBrowser.ApiInteraction.Portable</AssemblyName>- <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>- <TargetFrameworkProfile>Profile4</TargetFrameworkProfile>- <FileAlignment>512</FileAlignment>- <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>- </PropertyGroup>- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">- <DebugSymbols>true</DebugSymbols>- <DebugType>full</DebugType>- <Optimize>false</Optimize>- <OutputPath>bin\Debug\</OutputPath>- <DefineConstants>DEBUG;TRACE</DefineConstants>- <ErrorReport>prompt</ErrorReport>- <WarningLevel>4</WarningLevel>- </PropertyGroup>- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">- <DebugType>pdbonly</DebugType>- <Optimize>true</Optimize>- <OutputPath>bin\Release\</OutputPath>- <DefineConstants>TRACE</DefineConstants>- <ErrorReport>prompt</ErrorReport>- <WarningLevel>4</WarningLevel>- </PropertyGroup>- <ItemGroup>- <Compile Include="..\MediaBrowser.ApiInteraction\BaseApiClient.cs">- <Link>BaseApiClient.cs</Link>- </Compile>- <Compile Include="..\MediaBrowser.ApiInteraction.Metro\DataSerializer.cs">- <Link>DataSerializer.cs</Link>- </Compile>- <Compile Include="..\MediaBrowser.ApiInteraction\SerializationFormats.cs">- <Link>SerializationFormats.cs</Link>- </Compile>- <Compile Include="ApiClient.cs" />- <Compile Include="Properties\AssemblyInfo.cs" />- </ItemGroup>- <ItemGroup>- <Reference Include="Newtonsoft.Json">- <HintPath>..\Json.Net\Portable\Newtonsoft.Json.dll</HintPath>- </Reference>- <Reference Include="protobuf-net">- <HintPath>..\protobuf-net\Full\portable\protobuf-net.dll</HintPath>- </Reference>- <Reference Include="ProtobufModelSerializer">- <HintPath>..\MediaBrowser.Model\bin\ProtobufModelSerializer.dll</HintPath>- </Reference>- </ItemGroup>- <ItemGroup>- <ProjectReference Include="..\MediaBrowser.Model\MediaBrowser.Model.csproj">- <Project>{7eeeb4bb-f3e8-48fc-b4c5-70f0fff8329b}</Project>- <Name>MediaBrowser.Model</Name>- </ProjectReference>- </ItemGroup>- <Import Project="$(MSBuildExtensionsPath32)\Microsoft\Portable\$(TargetFrameworkVersion)\Microsoft.Portable.CSharp.targets" />- <!-- To modify your build process, add your task inside one of the targets below and uncomment it.- Other similar extension points exist, see Microsoft.Common.targets.- <Target Name="BeforeBuild">- </Target>- <Target Name="AfterBuild">- </Target>- -->-</Project>\ No newline at end of filediff --git a/MediaBrowser.ApiInteraction.Portable/Properties/AssemblyInfo.cs b/MediaBrowser.ApiInteraction.Portable/Properties/AssemblyInfo.csdeleted file mode 100644index c7628135dc..0000000000--- a/MediaBrowser.ApiInteraction.Portable/Properties/AssemblyInfo.cs+++ /dev/null@@ -1,30 +0,0 @@-using System.Resources;-using System.Reflection;-using System.Runtime.CompilerServices;-using System.Runtime.InteropServices;--// General Information about an assembly is controlled through the following-// set of attributes. Change these attribute values to modify the information-// associated with an assembly.-[assembly: AssemblyTitle("MediaBrowser.ApiInteraction.Portable")]-[assembly: AssemblyDescription("")]-[assembly: AssemblyConfiguration("")]-[assembly: AssemblyCompany("")]-[assembly: AssemblyProduct("MediaBrowser.ApiInteraction.Portable")]-[assembly: AssemblyCopyright("Copyright © 2012")]-[assembly: AssemblyTrademark("")]-[assembly: AssemblyCulture("")]-[assembly: NeutralResourcesLanguage("en")]--// Version information for an assembly consists of the following four values:-//-// Major Version-// Minor Version-// Build Number-// Revision-//-// You can specify all the values or you can default the Build and Revision Numbers-// by using the '*' as shown below:-// [assembly: AssemblyVersion("1.0.*")]-[assembly: AssemblyVersion("1.0.0.0")]-[assembly: AssemblyFileVersion("1.0.0.0")]diff --git a/MediaBrowser.ApiInteraction.sln b/MediaBrowser.ApiInteraction.slnindex b5bcc1cddb..4484801a2b 100644--- a/MediaBrowser.ApiInteraction.sln+++ b/MediaBrowser.ApiInteraction.sln@@ -12,18 +12,12 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".nuget", ".nuget", "{F0E0E6EndProjectProject("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MediaBrowser.ApiInteraction.Metro", "MediaBrowser.ApiInteraction.Metro\MediaBrowser.ApiInteraction.Metro.csproj", "{94CEA07A-307C-4663-AA43-7BD852808574}"EndProject-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MediaBrowser.ApiInteraction.Portable", "MediaBrowser.ApiInteraction.Portable\MediaBrowser.ApiInteraction.Portable.csproj", "{756B93D2-5FFA-4B8D-BDCA-127476F1E6FB}"-EndProjectGlobalGlobalSection(SolutionConfigurationPlatforms) = preSolutionDebug|Any CPU = Debug|Any CPURelease|Any CPU = Release|Any CPUEndGlobalSectionGlobalSection(ProjectConfigurationPlatforms) = postSolution- {756B93D2-5FFA-4B8D-BDCA-127476F1E6FB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU- {756B93D2-5FFA-4B8D-BDCA-127476F1E6FB}.Debug|Any CPU.Build.0 = Debug|Any CPU- {756B93D2-5FFA-4B8D-BDCA-127476F1E6FB}.Release|Any CPU.ActiveCfg = Release|Any CPU- {756B93D2-5FFA-4B8D-BDCA-127476F1E6FB}.Release|Any CPU.Build.0 = Release|Any CPU{7EEEB4BB-F3E8-48FC-B4C5-70F0FFF8329B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU{7EEEB4BB-F3E8-48FC-B4C5-70F0FFF8329B}.Debug|Any CPU.Build.0 = Debug|Any CPU{7EEEB4BB-F3E8-48FC-B4C5-70F0FFF8329B}.Release|Any CPU.ActiveCfg = Release|Any CPUdiff --git a/MediaBrowser.ApiInteraction/BaseApiClient.cs b/MediaBrowser.ApiInteraction/BaseApiClient.csindex 7952129cf4..18588e9204 100644--- a/MediaBrowser.ApiInteraction/BaseApiClient.cs+++ b/MediaBrowser.ApiInteraction/BaseApiClient.cs@@ -299,7 +299,7 @@ namespace MediaBrowser.ApiInteraction/// <param name="maxWidth">Use if a max width is required. Aspect ratio will be preserved.</param>/// <param name="maxHeight">Use if a max height is required. Aspect ratio will be preserved.</param>/// <param name="quality">Quality level, from 0-100. Currently only applies to JPG. The default value should suffice.</param>- public string[] GetBackdropImageUrls(DTOBaseItem item, int? width = null, int? height = null, int? maxWidth = null, int? maxHeight = null, int? quality = null)+ public string[] GetBackdropImageUrls(DtoBaseItem item, int? width = null, int? height = null, int? maxWidth = null, int? maxHeight = null, int? quality = null){Guid? backdropItemId = null;int backdropCount = 0;@@ -339,7 +339,7 @@ namespace MediaBrowser.ApiInteraction/// <param name="maxWidth">Use if a max width is required. Aspect ratio will be preserved.</param>/// <param name="maxHeight">Use if a max height is required. Aspect ratio will be preserved.</param>/// <param name="quality">Quality level, from 0-100. Currently only applies to JPG. The default value should suffice.</param>- public string GetLogoImageUrl(DTOBaseItem item, int? width = null, int? height = null, int? maxWidth = null, int? maxHeight = null, int? quality = null)+ public string GetLogoImageUrl(DtoBaseItem item, int? width = null, int? height = null, int? maxWidth = null, int? maxHeight = null, int? quality = null){Guid? logoItemId = item.HasLogo ? item.Id : item.ParentLogoItemId;diff --git a/MediaBrowser.ApiInteraction/BaseHttpApiClient.cs b/MediaBrowser.ApiInteraction/BaseHttpApiClient.csindex 0b87ef4cd1..6bc052afcb 100644--- a/MediaBrowser.ApiInteraction/BaseHttpApiClient.cs+++ b/MediaBrowser.ApiInteraction/BaseHttpApiClient.cs@@ -50,7 +50,7 @@ namespace MediaBrowser.ApiInteraction/// <summary>/// Gets a BaseItem/// </summary>- public async Task<DTOBaseItem> GetItemAsync(Guid id, Guid userId)+ public async Task<DtoBaseItem> GetItemAsync(Guid id, Guid userId){string url = ApiUrl + "/item?userId=" + userId.ToString();@@ -61,20 +61,20 @@ namespace MediaBrowser.ApiInteractionusing (Stream stream = await GetSerializedStreamAsync(url).ConfigureAwait(false)){- return DeserializeFromStream<DTOBaseItem>(stream);+ return DeserializeFromStream<DtoBaseItem>(stream);}}/// <summary>/// Gets all Users/// </summary>- public async Task<DTOUser[]> GetAllUsersAsync()+ public async Task<DtoUser[]> GetAllUsersAsync(){string url = ApiUrl + "/users";using (Stream stream = await GetSerializedStreamAsync(url).ConfigureAwait(false)){- return DeserializeFromStream<DTOUser[]>(stream);+ return DeserializeFromStream<DtoUser[]>(stream);}}@@ -96,7 +96,7 @@ namespace MediaBrowser.ApiInteraction/// </summary>/// <param name="userId">The user id.</param>/// <param name="folderId">(Optional) Specify a folder Id to localize the search to a specific folder.</param>- public async Task<DTOBaseItem[]> GetInProgressItemsItemsAsync(Guid userId, Guid? folderId = null)+ public async Task<DtoBaseItem[]> GetInProgressItemsItemsAsync(Guid userId, Guid? folderId = null){string url = ApiUrl + "/itemlist?listtype=inprogressitems&userId=" + userId.ToString();@@ -107,7 +107,7 @@ namespace MediaBrowser.ApiInteractionusing (Stream stream = await GetSerializedStreamAsync(url).ConfigureAwait(false)){- return DeserializeFromStream<DTOBaseItem[]>(stream);+ return DeserializeFromStream<DtoBaseItem[]>(stream);}}@@ -116,7 +116,7 @@ namespace MediaBrowser.ApiInteraction/// </summary>/// <param name="userId">The user id.</param>/// <param name="folderId">(Optional) Specify a folder Id to localize the search to a specific folder.</param>- public async Task<DTOBaseItem[]> GetRecentlyAddedItemsAsync(Guid userId, Guid? folderId = null)+ public async Task<DtoBaseItem[]> GetRecentlyAddedItemsAsync(Guid userId, Guid? folderId = null){string url = ApiUrl + "/itemlist?listtype=recentlyaddeditems&userId=" + userId.ToString();@@ -127,7 +127,7 @@ namespace MediaBrowser.ApiInteractionusing (Stream stream = await GetSerializedStreamAsync(url).ConfigureAwait(false)){- return DeserializeFromStream<DTOBaseItem[]>(stream);+ return DeserializeFromStream<DtoBaseItem[]>(stream);}}@@ -136,7 +136,7 @@ namespace MediaBrowser.ApiInteraction/// </summary>/// <param name="userId">The user id.</param>/// <param name="folderId">(Optional) Specify a folder Id to localize the search to a specific folder.</param>- public async Task<DTOBaseItem[]> GetFavoriteItemsAsync(Guid userId, Guid? folderId = null)+ public async Task<DtoBaseItem[]> GetFavoriteItemsAsync(Guid userId, Guid? folderId = null){string url = ApiUrl + "/itemlist?listtype=favorites&userId=" + userId.ToString();@@ -147,7 +147,7 @@ namespace MediaBrowser.ApiInteractionusing (Stream stream = await GetSerializedStreamAsync(url).ConfigureAwait(false)){- return DeserializeFromStream<DTOBaseItem[]>(stream);+ return DeserializeFromStream<DtoBaseItem[]>(stream);}}@@ -156,7 +156,7 @@ namespace MediaBrowser.ApiInteraction/// </summary>/// <param name="userId">The user id.</param>/// <param name="folderId">(Optional) Specify a folder Id to localize the search to a specific folder.</param>- public async Task<DTOBaseItem[]> GetRecentlyAddedUnplayedItemsAsync(Guid userId, Guid? folderId = null)+ public async Task<DtoBaseItem[]> GetRecentlyAddedUnplayedItemsAsync(Guid userId, Guid? folderId = null){string url = ApiUrl + "/itemlist?listtype=recentlyaddedunplayeditems&userId=" + userId.ToString();@@ -167,7 +167,7 @@ namespace MediaBrowser.ApiInteractionusing (Stream stream = await GetSerializedStreamAsync(url).ConfigureAwait(false)){- return DeserializeFromStream<DTOBaseItem[]>(stream);+ return DeserializeFromStream<DtoBaseItem[]>(stream);}}@@ -188,7 +188,7 @@ namespace MediaBrowser.ApiInteraction/// Gets all items that contain a given Year/// </summary>/// <param name="folderId">(Optional) Specify a folder Id to localize the search to a specific folder.</param>- public async Task<DTOBaseItem[]> GetItemsWithYearAsync(string name, Guid userId, Guid? folderId = null)+ public async Task<DtoBaseItem[]> GetItemsWithYearAsync(string name, Guid userId, Guid? folderId = null){string url = ApiUrl + "/itemlist?listtype=itemswithyear&userId=" + userId.ToString() + "&name=" + name;@@ -199,7 +199,7 @@ namespace MediaBrowser.ApiInteractionusing (Stream stream = await GetSerializedStreamAsync(url).ConfigureAwait(false)){- return DeserializeFromStream<DTOBaseItem[]>(stream);+ return DeserializeFromStream<DtoBaseItem[]>(stream);}}@@ -207,7 +207,7 @@ namespace MediaBrowser.ApiInteraction/// Gets all items that contain a given Genre/// </summary>/// <param name="folderId">(Optional) Specify a folder Id to localize the search to a specific folder.</param>- public async Task<DTOBaseItem[]> GetItemsWithGenreAsync(string name, Guid userId, Guid? folderId = null)+ public async Task<DtoBaseItem[]> GetItemsWithGenreAsync(string name, Guid userId, Guid? folderId = null){string url = ApiUrl + "/itemlist?listtype=itemswithgenre&userId=" + userId.ToString() + "&name=" + name;@@ -218,7 +218,7 @@ namespace MediaBrowser.ApiInteractionusing (Stream stream = await GetSerializedStreamAsync(url).ConfigureAwait(false)){- return DeserializeFromStream<DTOBaseItem[]>(stream);+ return DeserializeFromStream<DtoBaseItem[]>(stream);}}@@ -226,7 +226,7 @@ namespace MediaBrowser.ApiInteraction/// Gets all items that contain a given Person/// </summary>/// <param name="folderId">(Optional) Specify a folder Id to localize the search to a specific folder.</param>- public async Task<DTOBaseItem[]> GetItemsWithPersonAsync(string name, Guid userId, Guid? folderId = null)+ public async Task<DtoBaseItem[]> GetItemsWithPersonAsync(string name, Guid userId, Guid? folderId = null){string url = ApiUrl + "/itemlist?listtype=itemswithperson&userId=" + userId.ToString() + "&name=" + name;@@ -237,7 +237,7 @@ namespace MediaBrowser.ApiInteractionusing (Stream stream = await GetSerializedStreamAsync(url).ConfigureAwait(false)){- return DeserializeFromStream<DTOBaseItem[]>(stream);+ return DeserializeFromStream<DtoBaseItem[]>(stream);}}@@ -245,7 +245,7 @@ namespace MediaBrowser.ApiInteraction/// Gets all items that contain a given Person/// </summary>/// <param name="folderId">(Optional) Specify a folder Id to localize the search to a specific folder.</param>- public async Task<DTOBaseItem[]> GetItemsWithPersonAsync(string name, string personType, Guid userId, Guid? folderId = null)+ public async Task<DtoBaseItem[]> GetItemsWithPersonAsync(string name, string personType, Guid userId, Guid? folderId = null){string url = ApiUrl + "/itemlist?listtype=itemswithperson&userId=" + userId.ToString() + "&name=" + name;@@ -258,7 +258,7 @@ namespace MediaBrowser.ApiInteractionusing (Stream stream = await GetSerializedStreamAsync(url).ConfigureAwait(false)){- return DeserializeFromStream<DTOBaseItem[]>(stream);+ return DeserializeFromStream<DtoBaseItem[]>(stream);}}@@ -279,7 +279,7 @@ namespace MediaBrowser.ApiInteraction/// Gets all items that contain a given Studio/// </summary>/// <param name="folderId">(Optional) Specify a folder Id to localize the search to a specific folder.</param>- public async Task<DTOBaseItem[]> GetItemsWithStudioAsync(string name, Guid userId, Guid? folderId = null)+ public async Task<DtoBaseItem[]> GetItemsWithStudioAsync(string name, Guid userId, Guid? folderId = null){string url = ApiUrl + "/itemlist?listtype=itemswithstudio&userId=" + userId.ToString() + "&name=" + name;@@ -290,7 +290,7 @@ namespace MediaBrowser.ApiInteractionusing (Stream stream = await GetSerializedStreamAsync(url).ConfigureAwait(false)){- return DeserializeFromStream<DTOBaseItem[]>(stream);+ return DeserializeFromStream<DtoBaseItem[]>(stream);}}@@ -401,26 +401,26 @@ namespace MediaBrowser.ApiInteraction/// <summary>/// Gets the default user/// </summary>- public async Task<DTOUser> GetDefaultUserAsync()+ public async Task<DtoUser> GetDefaultUserAsync(){string url = ApiUrl + "/user";using (Stream stream = await GetSerializedStreamAsync(url).ConfigureAwait(false)){- return DeserializeFromStream<DTOUser>(stream);+ return DeserializeFromStream<DtoUser>(stream);}}/// <summary>/// Gets a user by id/// </summary>- public async Task<DTOUser> GetUserAsync(Guid id)+ public async Task<DtoUser> GetUserAsync(Guid id){string url = ApiUrl + "/user?id=" + id.ToString();using (Stream stream = await GetSerializedStreamAsync(url).ConfigureAwait(false)){- return DeserializeFromStream<DTOUser>(stream);+ return DeserializeFromStream<DtoUser>(stream);}}@@ -453,21 +453,21 @@ namespace MediaBrowser.ApiInteraction/// <summary>/// Gets special features for a Movie/// </summary>- public async Task<DTOBaseItem[]> GetMovieSpecialFeaturesAsync(Guid itemId, Guid userId)+ public async Task<DtoBaseItem[]> GetMovieSpecialFeaturesAsync(Guid itemId, Guid userId){string url = ApiUrl + "/MovieSpecialFeatures?id=" + itemId;url += "&userid=" + userId;using (Stream stream = await GetSerializedStreamAsync(url).ConfigureAwait(false)){- return DeserializeFromStream<DTOBaseItem[]>(stream);+ return DeserializeFromStream<DtoBaseItem[]>(stream);}}/// <summary>/// Updates played status for an item/// </summary>- public async Task<DTOUserItemData> UpdatePlayedStatusAsync(Guid itemId, Guid userId, bool wasPlayed)+ public async Task<DtoUserItemData> UpdatePlayedStatusAsync(Guid itemId, Guid userId, bool wasPlayed){string url = ApiUrl + "/PlayedStatus?id=" + itemId;@@ -476,14 +476,14 @@ namespace MediaBrowser.ApiInteractionusing (Stream stream = await GetSerializedStreamAsync(url).ConfigureAwait(false)){- return DeserializeFromStream<DTOUserItemData>(stream);+ return DeserializeFromStream<DtoUserItemData>(stream);}}/// <summary>/// Updates a user's favorite status for an item and returns the updated UserItemData object./// </summary>- public async Task<DTOUserItemData> UpdateFavoriteStatusAsync(Guid itemId, Guid userId, bool isFavorite)+ public async Task<DtoUserItemData> UpdateFavoriteStatusAsync(Guid itemId, Guid userId, bool isFavorite){string url = ApiUrl + "/favoritestatus?id=" + itemId;@@ -492,14 +492,14 @@ namespace MediaBrowser.ApiInteractionusing (Stream stream = await GetSerializedStreamAsync(url).ConfigureAwait(false)){- return DeserializeFromStream<DTOUserItemData>(stream);+ return DeserializeFromStream<DtoUserItemData>(stream);}}/// <summary>/// Clears a user's rating for an item/// </summary>- public async Task<DTOUserItemData> ClearUserItemRatingAsync(Guid itemId, Guid userId)+ public async Task<DtoUserItemData> ClearUserItemRatingAsync(Guid itemId, Guid userId){string url = ApiUrl + "/UserItemRating?id=" + itemId;@@ -508,14 +508,14 @@ namespace MediaBrowser.ApiInteractionusing (Stream stream = await GetSerializedStreamAsync(url).ConfigureAwait(false)){- return DeserializeFromStream<DTOUserItemData>(stream);+ return DeserializeFromStream<DtoUserItemData>(stream);}}/// <summary>/// Updates a user's rating for an item, based on likes or dislikes/// </summary>- public async Task<DTOUserItemData> UpdateUserItemRatingAsync(Guid itemId, Guid userId, bool likes)+ public async Task<DtoUserItemData> UpdateUserItemRatingAsync(Guid itemId, Guid userId, bool likes){string url = ApiUrl + "/UserItemRating?id=" + itemId;@@ -524,7 +524,7 @@ namespace MediaBrowser.ApiInteractionusing (Stream stream = await GetSerializedStreamAsync(url).ConfigureAwait(false)){- return DeserializeFromStream<DTOUserItemData>(stream);+ return DeserializeFromStream<DtoUserItemData>(stream);}}diff --git a/MediaBrowser.ApiInteraction/DataSerializer.cs b/MediaBrowser.ApiInteraction/DataSerializer.csindex ae3a72e622..2783f4ea12 100644--- a/MediaBrowser.ApiInteraction/DataSerializer.cs+++ b/MediaBrowser.ApiInteraction/DataSerializer.cs@@ -12,7 +12,7 @@ namespace MediaBrowser.ApiInteraction/// This means that this class can currently only handle types within the Model project./// If we need to, we can always add a param indicating whether or not the model serializer should be used./// </summary>- private static ProtobufModelSerializer ProtobufModelSerializer = new ProtobufModelSerializer();+ private static readonly ProtobufModelSerializer ProtobufModelSerializer = new ProtobufModelSerializer();/// <summary>/// Deserializes an object using generics@@ -20,16 +20,16 @@ namespace MediaBrowser.ApiInteractionpublic static T DeserializeFromStream<T>(Stream stream, SerializationFormats format)where T : class{- if (format == ApiInteraction.SerializationFormats.Protobuf)+ if (format == SerializationFormats.Protobuf){//return Serializer.Deserialize<T>(stream);return ProtobufModelSerializer.Deserialize(stream, null, typeof(T)) as T;}- else if (format == ApiInteraction.SerializationFormats.Jsv)+ else if (format == SerializationFormats.Jsv){return TypeSerializer.DeserializeFromStream<T>(stream);}- else if (format == ApiInteraction.SerializationFormats.Json)+ else if (format == SerializationFormats.Json){return JsonSerializer.DeserializeFromStream<T>(stream);}diff --git a/MediaBrowser.ApiInteraction/Properties/AssemblyInfo.cs b/MediaBrowser.ApiInteraction/Properties/AssemblyInfo.csindex 5dd263f0a0..74742759f3 100644--- a/MediaBrowser.ApiInteraction/Properties/AssemblyInfo.cs+++ b/MediaBrowser.ApiInteraction/Properties/AssemblyInfo.cs@@ -1,5 +1,4 @@using System.Reflection;-using System.Runtime.CompilerServices;using System.Runtime.InteropServices;// General Information about an assembly is controlled through the followingdiff --git a/MediaBrowser.Common/Kernel/BaseKernel.cs b/MediaBrowser.Common/Kernel/BaseKernel.csindex 3c8fff2128..7f484acaa6 100644--- a/MediaBrowser.Common/Kernel/BaseKernel.cs+++ b/MediaBrowser.Common/Kernel/BaseKernel.cs@@ -67,7 +67,7 @@ namespace MediaBrowser.Common.Kernel/// </summary>public abstract KernelContext KernelContext { get; }- public BaseKernel()+ protected BaseKernel(){ApplicationPaths = new TApplicationPathsType();}@@ -76,13 +76,13 @@ namespace MediaBrowser.Common.Kernel{ReloadLogger();- progress.Report(new TaskProgress() { Description = "Loading configuration", PercentComplete = 0 });+ progress.Report(new TaskProgress { Description = "Loading configuration", PercentComplete = 0 });ReloadConfiguration();- progress.Report(new TaskProgress() { Description = "Starting Http server", PercentComplete = 5 });+ progress.Report(new TaskProgress { Description = "Starting Http server", PercentComplete = 5 });ReloadHttpServer();- progress.Report(new TaskProgress() { Description = "Loading Plugins", PercentComplete = 10 });+ progress.Report(new TaskProgress { Description = "Loading Plugins", PercentComplete = 10 });await ReloadComposableParts().ConfigureAwait(false);}@@ -192,7 +192,7 @@ namespace MediaBrowser.Common.KernelHttpServer = new HttpServer(HttpServerUrlPrefix);- HttpListener = HttpServer.Subscribe((ctx) =>+ HttpListener = HttpServer.Subscribe(ctx =>{BaseHandler handler = HttpHandlers.FirstOrDefault(h => h.HandlesRequest(ctx.Request));diff --git a/MediaBrowser.Common/Logging/BaseLogger.cs b/MediaBrowser.Common/Logging/BaseLogger.csindex 16eb96e208..bcf10d7dc0 100644--- a/MediaBrowser.Common/Logging/BaseLogger.cs+++ b/MediaBrowser.Common/Logging/BaseLogger.cs@@ -67,7 +67,7 @@ namespace MediaBrowser.Common.LoggingThread currentThread = Thread.CurrentThread;- LogRow row = new LogRow()+ LogRow row = new LogRow{Severity = severity,Message = message,diff --git a/MediaBrowser.Common/Logging/LogRow.cs b/MediaBrowser.Common/Logging/LogRow.csindex 052f6062aa..6fecef59cc 100644--- a/MediaBrowser.Common/Logging/LogRow.cs+++ b/MediaBrowser.Common/Logging/LogRow.cs@@ -1,7 +1,5 @@using System;-using System.Text;using System.Collections.Generic;-using System.Linq;namespace MediaBrowser.Common.Logging{@@ -17,7 +15,7 @@ namespace MediaBrowser.Common.Loggingpublic override string ToString(){- List<string> data = new List<string>();+ var data = new List<string>();data.Add(Time.ToString(TimePattern));diff --git a/MediaBrowser.Common/Logging/StreamLogger.cs b/MediaBrowser.Common/Logging/StreamLogger.csindex caeb803bd1..03b9bd6d26 100644--- a/MediaBrowser.Common/Logging/StreamLogger.cs+++ b/MediaBrowser.Common/Logging/StreamLogger.cs@@ -7,7 +7,7 @@ namespace MediaBrowser.Common.Logging/// <summary>/// Provides a Logger that can write to any Stream/// </summary>- public class StreamLogger : ThreadedLogger+ public class StreamLogger : BaseLogger{private Stream Stream { get; set; }@@ -17,11 +17,15 @@ namespace MediaBrowser.Common.LoggingStream = stream;}- protected override void AsyncLogMessage(LogRow row)+ protected override void LogEntry(LogRow row){byte[] bytes = new UTF8Encoding().GetBytes(row.ToString() + Environment.NewLine);- Stream.Write(bytes, 0, bytes.Length);- Stream.Flush();++ lock (Stream)+ {+ Stream.Write(bytes, 0, bytes.Length);+ Stream.Flush();+ }}public override void Dispose()diff --git a/MediaBrowser.Common/Logging/ThreadedLogger.cs b/MediaBrowser.Common/Logging/ThreadedLogger.csdeleted file mode 100644index f53b3d4260..0000000000--- a/MediaBrowser.Common/Logging/ThreadedLogger.cs+++ /dev/null@@ -1,73 +0,0 @@-using System;-using System.Collections.Generic;-using System.Threading;--namespace MediaBrowser.Common.Logging-{- public abstract class ThreadedLogger : BaseLogger- {- Thread loggingThread;- Queue<Action> queue = new Queue<Action>();- AutoResetEvent hasNewItems = new AutoResetEvent(false);- volatile bool terminate = false;- bool waiting = false;-- public ThreadedLogger()- : base()- {- loggingThread = new Thread(new ThreadStart(ProcessQueue));- loggingThread.IsBackground = true;- loggingThread.Start();- }--- void ProcessQueue()- {- while (!terminate)- {- waiting = true;- hasNewItems.WaitOne(10000, true);- waiting = false;-- Queue<Action> queueCopy;- lock (queue)- {- queueCopy = new Queue<Action>(queue);- queue.Clear();- }-- foreach (var log in queueCopy)- {- log();- }- }- }-- protected override void LogEntry(LogRow row)- {- lock (queue)- {- queue.Enqueue(() => AsyncLogMessage(row));- }- hasNewItems.Set();- }-- protected abstract void AsyncLogMessage(LogRow row);-- protected override void Flush()- {- while (!waiting)- {- Thread.Sleep(1);- }- }-- public override void Dispose()- {- Flush();- terminate = true;- hasNewItems.Set();- base.Dispose();- }- }-}diff --git a/MediaBrowser.Common/MediaBrowser.Common.csproj b/MediaBrowser.Common/MediaBrowser.Common.csprojindex 9b801d9498..6eb5804ab1 100644--- a/MediaBrowser.Common/MediaBrowser.Common.csproj+++ b/MediaBrowser.Common/MediaBrowser.Common.csproj@@ -83,7 +83,6 @@<ItemGroup><Compile Include="Kernel\BaseApplicationPaths.cs" /><Compile Include="Drawing\DrawingUtils.cs" />- <Compile Include="Logging\ThreadedLogger.cs" /><Compile Include="Logging\TraceLogger.cs" /><Compile Include="Net\Handlers\StaticFileHandler.cs" /><Compile Include="Net\MimeTypes.cs" />diff --git a/MediaBrowser.Common/Net/Handlers/BaseEmbeddedResourceHandler.cs b/MediaBrowser.Common/Net/Handlers/BaseEmbeddedResourceHandler.csindex 9d9e2a0e03..3ce85a688d 100644--- a/MediaBrowser.Common/Net/Handlers/BaseEmbeddedResourceHandler.cs+++ b/MediaBrowser.Common/Net/Handlers/BaseEmbeddedResourceHandler.cs@@ -5,7 +5,7 @@ namespace MediaBrowser.Common.Net.Handlers{public abstract class BaseEmbeddedResourceHandler : BaseHandler{- public BaseEmbeddedResourceHandler(string resourcePath)+ protected BaseEmbeddedResourceHandler(string resourcePath): base(){ResourcePath = resourcePath;@@ -15,7 +15,7 @@ namespace MediaBrowser.Common.Net.Handlerspublic override Task<string> GetContentType(){- return Task.FromResult<string>(MimeTypes.GetMimeType(ResourcePath));+ return Task.FromResult(MimeTypes.GetMimeType(ResourcePath));}protected override Task WriteResponseToOutputStream(Stream stream)diff --git a/MediaBrowser.Common/Net/Handlers/BaseHandler.cs b/MediaBrowser.Common/Net/Handlers/BaseHandler.csindex ecc58b3165..7c18152655 100644--- a/MediaBrowser.Common/Net/Handlers/BaseHandler.cs+++ b/MediaBrowser.Common/Net/Handlers/BaseHandler.cs@@ -25,8 +25,8 @@ namespace MediaBrowser.Common.Net.Handlers}}- private bool _TotalContentLengthDiscovered = false;- private long? _TotalContentLength = null;+ private bool _TotalContentLengthDiscovered;+ private long? _TotalContentLength;public long? TotalContentLength{get@@ -34,6 +34,7 @@ namespace MediaBrowser.Common.Net.Handlersif (!_TotalContentLengthDiscovered){_TotalContentLength = GetTotalContentLength();+ _TotalContentLengthDiscovered = true;}return _TotalContentLength;@@ -64,7 +65,7 @@ namespace MediaBrowser.Common.Net.Handlers}}- protected List<KeyValuePair<long, long?>> _RequestedRanges = null;+ private List<KeyValuePair<long, long?>> _RequestedRanges;protected IEnumerable<KeyValuePair<long, long?>> RequestedRanges{get@@ -367,7 +368,7 @@ namespace MediaBrowser.Common.Net.Handlers{DateTime? value = null;- return Task.FromResult<DateTime?>(value);+ return Task.FromResult(value);}private bool IsResponseValid@@ -378,7 +379,7 @@ namespace MediaBrowser.Common.Net.Handlers}}- private Hashtable _FormValues = null;+ private Hashtable _FormValues;/// <summary>/// Gets a value from form POST datadiff --git a/MediaBrowser.Common/Net/Handlers/BaseSerializationHandler.cs b/MediaBrowser.Common/Net/Handlers/BaseSerializationHandler.csindex dd3020e035..1983c408de 100644--- a/MediaBrowser.Common/Net/Handlers/BaseSerializationHandler.cs+++ b/MediaBrowser.Common/Net/Handlers/BaseSerializationHandler.cs@@ -15,7 +15,7 @@ namespace MediaBrowser.Common.Net.Handlersif (string.IsNullOrEmpty(format)){- return Handlers.SerializationFormat.Json;+ return SerializationFormat.Json;}return (SerializationFormat)Enum.Parse(typeof(SerializationFormat), format, true);@@ -26,16 +26,16 @@ namespace MediaBrowser.Common.Net.Handlers{switch (SerializationFormat){- case Handlers.SerializationFormat.Jsv:- return Task.FromResult<string>("text/plain");- case Handlers.SerializationFormat.Protobuf:- return Task.FromResult<string>("application/x-protobuf");+ case SerializationFormat.Jsv:+ return Task.FromResult("text/plain");+ case SerializationFormat.Protobuf:+ return Task.FromResult("application/x-protobuf");default:- return Task.FromResult<string>(MimeTypes.JsonMimeType);+ return Task.FromResult(MimeTypes.JsonMimeType);}}- private bool _ObjectToSerializeEnsured = false;+ private bool _ObjectToSerializeEnsured;private T _ObjectToSerialize;private async Task EnsureObjectToSerialize()@@ -66,14 +66,14 @@ namespace MediaBrowser.Common.Net.Handlersswitch (SerializationFormat){- case Handlers.SerializationFormat.Jsv:- JsvSerializer.SerializeToStream<T>(_ObjectToSerialize, stream);+ case SerializationFormat.Jsv:+ JsvSerializer.SerializeToStream(_ObjectToSerialize, stream);break;- case Handlers.SerializationFormat.Protobuf:- ProtobufSerializer.SerializeToStream<T>(_ObjectToSerialize, stream);+ case SerializationFormat.Protobuf:+ ProtobufSerializer.SerializeToStream(_ObjectToSerialize, stream);break;default:- JsonSerializer.SerializeToStream<T>(_ObjectToSerialize, stream);+ JsonSerializer.SerializeToStream(_ObjectToSerialize, stream);break;}}diff --git a/MediaBrowser.Common/Net/Handlers/StaticFileHandler.cs b/MediaBrowser.Common/Net/Handlers/StaticFileHandler.csindex bc367403b8..f5c4413102 100644--- a/MediaBrowser.Common/Net/Handlers/StaticFileHandler.cs+++ b/MediaBrowser.Common/Net/Handlers/StaticFileHandler.cs@@ -33,8 +33,8 @@ namespace MediaBrowser.Common.Net.Handlers}}- private bool _SourceStreamEnsured = false;- private Stream _SourceStream = null;+ private bool _SourceStreamEnsured;+ private Stream _SourceStream;private Stream SourceStream{get@@ -116,12 +116,12 @@ namespace MediaBrowser.Common.Net.Handlersvalue = File.GetLastWriteTimeUtc(Path);}- return Task.FromResult<DateTime?>(value);+ return Task.FromResult(value);}public override Task<string> GetContentType(){- return Task.FromResult<string>(MimeTypes.GetMimeType(Path));+ return Task.FromResult(MimeTypes.GetMimeType(Path));}protected override Task PrepareResponse()@@ -141,21 +141,17 @@ namespace MediaBrowser.Common.Net.Handlers{return ServeCompleteRangeRequest(requestedRange, stream);}- else if (TotalContentLength.HasValue)+ if (TotalContentLength.HasValue){// This will have to buffer a portion of the content into memoryreturn ServePartialRangeRequestWithKnownTotalContentLength(requestedRange, stream);}- else- {- // This will have to buffer the entire content into memory- return ServePartialRangeRequestWithUnknownTotalContentLength(requestedRange, stream);- }- }- else- {- return SourceStream.CopyToAsync(stream);++ // This will have to buffer the entire content into memory+ return ServePartialRangeRequestWithUnknownTotalContentLength(requestedRange, stream);}++ return SourceStream.CopyToAsync(stream);}protected override void DisposeResponseStream()diff --git a/MediaBrowser.Common/Net/HttpServer.cs b/MediaBrowser.Common/Net/HttpServer.csindex 69ded6f816..1b3a272f11 100644--- a/MediaBrowser.Common/Net/HttpServer.cs+++ b/MediaBrowser.Common/Net/HttpServer.cs@@ -20,7 +20,7 @@ namespace MediaBrowser.Common.Netprivate IObservable<HttpListenerContext> ObservableHttpContext(){return Observable.Create<HttpListenerContext>(obs =>- Observable.FromAsync<HttpListenerContext>(() => listener.GetContextAsync())+ Observable.FromAsync(() => listener.GetContextAsync()).Subscribe(obs)).Repeat().Retry()diff --git a/MediaBrowser.Common/Net/MimeTypes.cs b/MediaBrowser.Common/Net/MimeTypes.csindex 3ec13ce83f..fb85b0f2a3 100644--- a/MediaBrowser.Common/Net/MimeTypes.cs+++ b/MediaBrowser.Common/Net/MimeTypes.cs@@ -9,7 +9,7 @@ namespace MediaBrowser.Common.Netpublic static string GetMimeType(string path){- string ext = Path.GetExtension(path);+ var ext = Path.GetExtension(path);// http://en.wikipedia.org/wiki/Internet_media_type// Add more as needed@@ -19,137 +19,137 @@ namespace MediaBrowser.Common.Net{return "video/mpeg";}- else if (ext.EndsWith("mp4", StringComparison.OrdinalIgnoreCase))+ if (ext.EndsWith("mp4", StringComparison.OrdinalIgnoreCase)){return "video/mp4";}- else if (ext.EndsWith("ogv", StringComparison.OrdinalIgnoreCase))+ if (ext.EndsWith("ogv", StringComparison.OrdinalIgnoreCase)){return "video/ogg";}- else if (ext.EndsWith("mov", StringComparison.OrdinalIgnoreCase))+ if (ext.EndsWith("mov", StringComparison.OrdinalIgnoreCase)){return "video/quicktime";}- else if (ext.EndsWith("webm", StringComparison.OrdinalIgnoreCase))+ if (ext.EndsWith("webm", StringComparison.OrdinalIgnoreCase)){return "video/webm";}- else if (ext.EndsWith("mkv", StringComparison.OrdinalIgnoreCase))+ if (ext.EndsWith("mkv", StringComparison.OrdinalIgnoreCase)){return "video/x-matroska";}- else if (ext.EndsWith("wmv", StringComparison.OrdinalIgnoreCase))+ if (ext.EndsWith("wmv", StringComparison.OrdinalIgnoreCase)){return "video/x-ms-wmv";}- else if (ext.EndsWith("flv", StringComparison.OrdinalIgnoreCase))+ if (ext.EndsWith("flv", StringComparison.OrdinalIgnoreCase)){return "video/x-flv";}- else if (ext.EndsWith("avi", StringComparison.OrdinalIgnoreCase))+ if (ext.EndsWith("avi", StringComparison.OrdinalIgnoreCase)){return "video/avi";}- else if (ext.EndsWith("m4v", StringComparison.OrdinalIgnoreCase))+ if (ext.EndsWith("m4v", StringComparison.OrdinalIgnoreCase)){return "video/x-m4v";}- else if (ext.EndsWith("asf", StringComparison.OrdinalIgnoreCase))+ if (ext.EndsWith("asf", StringComparison.OrdinalIgnoreCase)){return "video/x-ms-asf";}- else if (ext.EndsWith("3gp", StringComparison.OrdinalIgnoreCase))+ if (ext.EndsWith("3gp", StringComparison.OrdinalIgnoreCase)){return "video/3gpp";}- else if (ext.EndsWith("3g2", StringComparison.OrdinalIgnoreCase))+ if (ext.EndsWith("3g2", StringComparison.OrdinalIgnoreCase)){return "video/3gpp2";}- else if (ext.EndsWith("ts", StringComparison.OrdinalIgnoreCase))+ if (ext.EndsWith("ts", StringComparison.OrdinalIgnoreCase)){return "video/mp2t";}// Type text- else if (ext.EndsWith("css", StringComparison.OrdinalIgnoreCase))+ if (ext.EndsWith("css", StringComparison.OrdinalIgnoreCase)){return "text/css";}- else if (ext.EndsWith("csv", StringComparison.OrdinalIgnoreCase))+ if (ext.EndsWith("csv", StringComparison.OrdinalIgnoreCase)){return "text/csv";}- else if (ext.EndsWith("html", StringComparison.OrdinalIgnoreCase) || ext.EndsWith("html", StringComparison.OrdinalIgnoreCase))+ if (ext.EndsWith("html", StringComparison.OrdinalIgnoreCase) || ext.EndsWith("html", StringComparison.OrdinalIgnoreCase)){return "text/html";}- else if (ext.EndsWith("txt", StringComparison.OrdinalIgnoreCase))+ if (ext.EndsWith("txt", StringComparison.OrdinalIgnoreCase)){return "text/plain";}// Type image- else if (ext.EndsWith("gif", StringComparison.OrdinalIgnoreCase))+ if (ext.EndsWith("gif", StringComparison.OrdinalIgnoreCase)){return "image/gif";}- else if (ext.EndsWith("jpg", StringComparison.OrdinalIgnoreCase) || ext.EndsWith("jpeg", StringComparison.OrdinalIgnoreCase))+ if (ext.EndsWith("jpg", StringComparison.OrdinalIgnoreCase) || ext.EndsWith("jpeg", StringComparison.OrdinalIgnoreCase)){return "image/jpeg";}- else if (ext.EndsWith("png", StringComparison.OrdinalIgnoreCase))+ if (ext.EndsWith("png", StringComparison.OrdinalIgnoreCase)){return "image/png";}- else if (ext.EndsWith("ico", StringComparison.OrdinalIgnoreCase))+ if (ext.EndsWith("ico", StringComparison.OrdinalIgnoreCase)){return "image/vnd.microsoft.icon";}// Type audio- else if (ext.EndsWith("mp3", StringComparison.OrdinalIgnoreCase))+ if (ext.EndsWith("mp3", StringComparison.OrdinalIgnoreCase)){return "audio/mpeg";}- else if (ext.EndsWith("m4a", StringComparison.OrdinalIgnoreCase) || ext.EndsWith("aac", StringComparison.OrdinalIgnoreCase))+ if (ext.EndsWith("m4a", StringComparison.OrdinalIgnoreCase) || ext.EndsWith("aac", StringComparison.OrdinalIgnoreCase)){return "audio/mp4";}- else if (ext.EndsWith("webma", StringComparison.OrdinalIgnoreCase))+ if (ext.EndsWith("webma", StringComparison.OrdinalIgnoreCase)){return "audio/webm";}- else if (ext.EndsWith("wav", StringComparison.OrdinalIgnoreCase))+ if (ext.EndsWith("wav", StringComparison.OrdinalIgnoreCase)){return "audio/wav";}- else if (ext.EndsWith("wma", StringComparison.OrdinalIgnoreCase))+ if (ext.EndsWith("wma", StringComparison.OrdinalIgnoreCase)){return "audio/x-ms-wma";}- else if (ext.EndsWith("flac", StringComparison.OrdinalIgnoreCase))+ if (ext.EndsWith("flac", StringComparison.OrdinalIgnoreCase)){return "audio/flac";}- else if (ext.EndsWith("aac", StringComparison.OrdinalIgnoreCase))+ if (ext.EndsWith("aac", StringComparison.OrdinalIgnoreCase)){return "audio/x-aac";}- else if (ext.EndsWith("ogg", StringComparison.OrdinalIgnoreCase) || ext.EndsWith("oga", StringComparison.OrdinalIgnoreCase))+ if (ext.EndsWith("ogg", StringComparison.OrdinalIgnoreCase) || ext.EndsWith("oga", StringComparison.OrdinalIgnoreCase)){return "audio/ogg";}// Playlists- else if (ext.EndsWith("m3u8", StringComparison.OrdinalIgnoreCase))+ if (ext.EndsWith("m3u8", StringComparison.OrdinalIgnoreCase)){return "application/x-mpegURL";}// Misc- else if (ext.EndsWith("dll", StringComparison.OrdinalIgnoreCase))+ if (ext.EndsWith("dll", StringComparison.OrdinalIgnoreCase)){return "application/x-msdownload";}diff --git a/MediaBrowser.Common/Plugins/BasePlugin.cs b/MediaBrowser.Common/Plugins/BasePlugin.csindex 705e15f173..1ed32109fb 100644--- a/MediaBrowser.Common/Plugins/BasePlugin.cs+++ b/MediaBrowser.Common/Plugins/BasePlugin.cs@@ -74,7 +74,7 @@ namespace MediaBrowser.Common.Plugins}}- private DateTime? _ConfigurationDateLastModified = null;+ private DateTime? _ConfigurationDateLastModified;public DateTime ConfigurationDateLastModified{get@@ -123,7 +123,7 @@ namespace MediaBrowser.Common.Plugins}}- private string _DataFolderPath = null;+ private string _DataFolderPath;/// <summary>/// Gets the full path to the data folder, where the plugin can store any miscellaneous files needed/// </summary>diff --git a/MediaBrowser.Common/Properties/AssemblyInfo.cs b/MediaBrowser.Common/Properties/AssemblyInfo.csindex 53e9df0f6e..ff70e8db7f 100644--- a/MediaBrowser.Common/Properties/AssemblyInfo.cs+++ b/MediaBrowser.Common/Properties/AssemblyInfo.cs@@ -1,5 +1,4 @@using System.Reflection;-using System.Runtime.CompilerServices;using System.Runtime.InteropServices;// General Information about an assembly is controlled through the followingdiff --git a/MediaBrowser.Common/Serialization/JsonSerializer.cs b/MediaBrowser.Common/Serialization/JsonSerializer.csindex bfca014a90..c44ceac1e5 100644--- a/MediaBrowser.Common/Serialization/JsonSerializer.cs+++ b/MediaBrowser.Common/Serialization/JsonSerializer.cs@@ -12,7 +12,7 @@ namespace MediaBrowser.Common.Serialization{Configure();- ServiceStack.Text.JsonSerializer.SerializeToStream<T>(obj, stream);+ ServiceStack.Text.JsonSerializer.SerializeToStream(obj, stream);}public static void SerializeToFile<T>(T obj, string file)@@ -21,7 +21,7 @@ namespace MediaBrowser.Common.Serializationusing (Stream stream = File.Open(file, FileMode.Create)){- ServiceStack.Text.JsonSerializer.SerializeToStream<T>(obj, stream);+ ServiceStack.Text.JsonSerializer.SerializeToStream(obj, stream);}}@@ -59,7 +59,7 @@ namespace MediaBrowser.Common.Serializationreturn ServiceStack.Text.JsonSerializer.DeserializeFromStream(type, stream);}- private static bool IsConfigured = false;+ private static bool IsConfigured;private static void Configure(){if (!IsConfigured)diff --git a/MediaBrowser.Common/Serialization/JsvSerializer.cs b/MediaBrowser.Common/Serialization/JsvSerializer.csindex d482348af4..41e5ea800a 100644--- a/MediaBrowser.Common/Serialization/JsvSerializer.cs+++ b/MediaBrowser.Common/Serialization/JsvSerializer.cs@@ -12,7 +12,7 @@ namespace MediaBrowser.Common.Serialization{public static void SerializeToStream<T>(T obj, Stream stream){- ServiceStack.Text.TypeSerializer.SerializeToStream<T>(obj, stream);+ ServiceStack.Text.TypeSerializer.SerializeToStream(obj, stream);}public static T DeserializeFromStream<T>(Stream stream)@@ -29,7 +29,7 @@ namespace MediaBrowser.Common.Serialization{using (Stream stream = File.Open(file, FileMode.Create)){- SerializeToStream<T>(obj, stream);+ SerializeToStream(obj, stream);}}diff --git a/MediaBrowser.Common/Serialization/ProtobufSerializer.cs b/MediaBrowser.Common/Serialization/ProtobufSerializer.csindex 7c8a5f96e7..1c79a272d5 100644--- a/MediaBrowser.Common/Serialization/ProtobufSerializer.cs+++ b/MediaBrowser.Common/Serialization/ProtobufSerializer.cs@@ -15,7 +15,7 @@ namespace MediaBrowser.Common.Serialization/// This means that this class can currently only handle types within the Model project./// If we need to, we can always add a param indicating whether or not the model serializer should be used./// </summary>- private static ProtobufModelSerializer ProtobufModelSerializer = new ProtobufModelSerializer();+ private static readonly ProtobufModelSerializer ProtobufModelSerializer = new ProtobufModelSerializer();public static void SerializeToStream<T>(T obj, Stream stream){@@ -37,7 +37,7 @@ namespace MediaBrowser.Common.Serialization{using (Stream stream = File.Open(file, FileMode.Create)){- SerializeToStream<T>(obj, stream);+ SerializeToStream(obj, stream);}}diff --git a/MediaBrowser.Common/Serialization/XmlSerializer.cs b/MediaBrowser.Common/Serialization/XmlSerializer.csindex b881591dd8..69853f97a6 100644--- a/MediaBrowser.Common/Serialization/XmlSerializer.cs+++ b/MediaBrowser.Common/Serialization/XmlSerializer.cs@@ -27,7 +27,7 @@ namespace MediaBrowser.Common.Serialization{using (FileStream stream = new FileStream(file, FileMode.Create)){- SerializeToStream<T>(obj, stream);+ SerializeToStream(obj, stream);}}diff --git a/MediaBrowser.Common/UI/BaseApplication.cs b/MediaBrowser.Common/UI/BaseApplication.csindex 4cbc57c0d3..d763f202f9 100644--- a/MediaBrowser.Common/UI/BaseApplication.cs+++ b/MediaBrowser.Common/UI/BaseApplication.cs@@ -19,7 +19,7 @@ namespace MediaBrowser.Common.UIprotected override void OnStartup(StartupEventArgs e){// Without this the app will shutdown after the splash screen closes- this.ShutdownMode = ShutdownMode.OnExplicitShutdown;+ ShutdownMode = ShutdownMode.OnExplicitShutdown;LoadKernel();}@@ -42,7 +42,7 @@ namespace MediaBrowser.Common.UILogger.LogInfo("Kernel.Init completed in {0} seconds.", (DateTime.UtcNow - now).TotalSeconds);splash.Close();- this.ShutdownMode = System.Windows.ShutdownMode.OnLastWindowClose;+ ShutdownMode = System.Windows.ShutdownMode.OnLastWindowClose;InstantiateMainWindow().ShowDialog();}catch (Exception ex)diff --git a/MediaBrowser.Common/UI/SingleInstance.cs b/MediaBrowser.Common/UI/SingleInstance.csindex 837d3bb578..2b2b6fb459 100644--- a/MediaBrowser.Common/UI/SingleInstance.cs+++ b/MediaBrowser.Common/UI/SingleInstance.cs@@ -13,18 +13,17 @@ namespace Microsoft.Shellusing System;using System.Collections;using System.Collections.Generic;+ using System.ComponentModel;using System.IO;+ using System.Runtime.InteropServices;using System.Runtime.Remoting;using System.Runtime.Remoting.Channels;using System.Runtime.Remoting.Channels.Ipc;using System.Runtime.Serialization.Formatters;+ using System.Security;using System.Threading;using System.Windows;using System.Windows.Threading;- using System.Xml.Serialization;- using System.Security;- using System.Runtime.InteropServices;- using System.ComponentModel;internal enum WM{@@ -184,7 +183,7 @@ namespace Microsoft.Shellfinally{- IntPtr p = _LocalFree(argv);+ _LocalFree(argv);// Otherwise LocalFree failed.// Assert.AreEqual(IntPtr.Zero, p);}diff --git a/MediaBrowser.Common/UI/Splash.xaml.cs b/MediaBrowser.Common/UI/Splash.xaml.csindex f66f9ec8fc..0956702295 100644--- a/MediaBrowser.Common/UI/Splash.xaml.cs+++ b/MediaBrowser.Common/UI/Splash.xaml.cs@@ -27,8 +27,8 @@ namespace MediaBrowser.Common.UILogger.LogInfo(e.Description);}- this.lblProgress.Content = e.Description;- this.pbProgress.Value = (double)e.PercentComplete;+ lblProgress.Content = e.Description;+ pbProgress.Value = (double)e.PercentComplete;}private void Splash_Loaded(object sender, RoutedEventArgs e)diff --git a/MediaBrowser.Controller/Entities/Folder.cs b/MediaBrowser.Controller/Entities/Folder.csindex c0f1604b1f..8d7fc40218 100644--- a/MediaBrowser.Controller/Entities/Folder.cs+++ b/MediaBrowser.Controller/Entities/Folder.cs@@ -61,7 +61,7 @@ namespace MediaBrowser.Controller.Entities/// </summary>public ItemSpecialCounts GetSpecialCounts(User user){- ItemSpecialCounts counts = new ItemSpecialCounts();+ var counts = new ItemSpecialCounts();IEnumerable<BaseItem> recursiveChildren = GetParentalAllowedRecursiveChildren(user);diff --git a/MediaBrowser.Controller/Entities/UserItemData.cs b/MediaBrowser.Controller/Entities/UserItemData.csindex 3eacdae5bc..271ecf5478 100644--- a/MediaBrowser.Controller/Entities/UserItemData.cs+++ b/MediaBrowser.Controller/Entities/UserItemData.cs@@ -5,7 +5,7 @@ namespace MediaBrowser.Controller.Entities{public class UserItemData{- private float? _Rating = null;+ private float? _Rating;/// <summary>/// Gets or sets the users 0-10 rating/// </summary>diff --git a/MediaBrowser.Controller/FFMpeg/FFProbe.cs b/MediaBrowser.Controller/FFMpeg/FFProbe.csindex d4c07f07b0..db113bb8a3 100644--- a/MediaBrowser.Controller/FFMpeg/FFProbe.cs+++ b/MediaBrowser.Controller/FFMpeg/FFProbe.cs@@ -61,7 +61,7 @@ namespace MediaBrowser.Controller.FFMpeg{try{- ProtobufSerializer.SerializeToFile<FFProbeResult>(result, outputCachePath);+ ProtobufSerializer.SerializeToFile(result, outputCachePath);}catch (Exception ex){diff --git a/MediaBrowser.Controller/IO/DirectoryWatchers.cs b/MediaBrowser.Controller/IO/DirectoryWatchers.csindex 837c02cb90..f8037984eb 100644--- a/MediaBrowser.Controller/IO/DirectoryWatchers.cs+++ b/MediaBrowser.Controller/IO/DirectoryWatchers.cs@@ -10,8 +10,8 @@ namespace MediaBrowser.Controller.IO{public class DirectoryWatchers{- private List<FileSystemWatcher> FileSystemWatchers = new List<FileSystemWatcher>();- private Timer updateTimer = null;+ private readonly List<FileSystemWatcher> FileSystemWatchers = new List<FileSystemWatcher>();+ private Timer updateTimer;private List<string> affectedPaths = new List<string>();private const int TimerDelayInSeconds = 5;@@ -107,10 +107,8 @@ namespace MediaBrowser.Controller.IO{return Kernel.Instance.ReloadRoot();}- else- {- return Task.WhenAll(itemsToRefresh.Select(i => Kernel.Instance.ReloadItem(i)));- }++ return Task.WhenAll(itemsToRefresh.Select(i => Kernel.Instance.ReloadItem(i)));}private BaseItem GetAffectedBaseItem(string path)diff --git a/MediaBrowser.Controller/IO/FileData.cs b/MediaBrowser.Controller/IO/FileData.csindex b7a6579daf..4ae2ee72f3 100644--- a/MediaBrowser.Controller/IO/FileData.cs+++ b/MediaBrowser.Controller/IO/FileData.cs@@ -149,7 +149,7 @@ namespace MediaBrowser.Controller.IOprivate static extern bool FindClose(IntPtr hFindFile);private const char SpaceChar = ' ';- private static char[] InvalidFileNameChars = Path.GetInvalidFileNameChars();+ private static readonly char[] InvalidFileNameChars = Path.GetInvalidFileNameChars();/// <summary>/// Takes a filename and removes invalid charactersdiff --git a/MediaBrowser.Controller/Kernel.cs b/MediaBrowser.Controller/Kernel.csindex 47a3773b34..0de57593b9 100644--- a/MediaBrowser.Controller/Kernel.cs+++ b/MediaBrowser.Controller/Kernel.cs@@ -93,13 +93,13 @@ namespace MediaBrowser.Controllerawait base.Init(progress).ConfigureAwait(false);- progress.Report(new TaskProgress() { Description = "Loading Users", PercentComplete = 15 });+ progress.Report(new TaskProgress { Description = "Loading Users", PercentComplete = 15 });ReloadUsers();- progress.Report(new TaskProgress() { Description = "Loading Media Library", PercentComplete = 25 });+ progress.Report(new TaskProgress { Description = "Loading Media Library", PercentComplete = 25 });await ReloadRoot(allowInternetProviders: false).ConfigureAwait(false);- progress.Report(new TaskProgress() { Description = "Loading Complete", PercentComplete = 100 });+ progress.Report(new TaskProgress { Description = "Loading Complete", PercentComplete = 100 });}protected override void OnComposablePartsLoaded()diff --git a/MediaBrowser.Controller/Library/ItemController.cs b/MediaBrowser.Controller/Library/ItemController.csindex 9e0c94b793..4115ea7b8b 100644--- a/MediaBrowser.Controller/Library/ItemController.cs+++ b/MediaBrowser.Controller/Library/ItemController.cs@@ -68,7 +68,7 @@ namespace MediaBrowser.Controller.Library/// </summary>public async Task<BaseItem> GetItem(string path, Folder parent = null, WIN32_FIND_DATA? fileInfo = null, bool allowInternetProviders = true){- ItemResolveEventArgs args = new ItemResolveEventArgs()+ var args = new ItemResolveEventArgs{FileInfo = fileInfo ?? FileData.GetFileData(path),Parent = parent,@@ -113,7 +113,7 @@ namespace MediaBrowser.Controller.Libraryif (item.IsFolder){// If it's a folder look for child entities- (item as Folder).Children = (await Task.WhenAll<BaseItem>(GetChildren(item as Folder, fileSystemChildren, allowInternetProviders)).ConfigureAwait(false))+ (item as Folder).Children = (await Task.WhenAll(GetChildren(item as Folder, fileSystemChildren, allowInternetProviders)).ConfigureAwait(false)).Where(i => i != null).OrderBy(f =>{return string.IsNullOrEmpty(f.SortName) ? f.Name : f.SortName;@@ -193,10 +193,8 @@ namespace MediaBrowser.Controller.LibraryresolvedShortcuts.InsertRange(0, returnArray);return resolvedShortcuts.ToArray();}- else- {- return returnArray;- }++ return returnArray;}/// <summary>@@ -231,7 +229,7 @@ namespace MediaBrowser.Controller.Libraryreturn GetImagesByNameItem<Year>(Kernel.Instance.ApplicationPaths.YearPath, value.ToString());}- private ConcurrentDictionary<string, object> ImagesByNameItemCache = new ConcurrentDictionary<string, object>(StringComparer.OrdinalIgnoreCase);+ private readonly ConcurrentDictionary<string, object> ImagesByNameItemCache = new ConcurrentDictionary<string, object>(StringComparer.OrdinalIgnoreCase);/// <summary>/// Generically retrieves an IBN itemdiff --git a/MediaBrowser.Controller/Properties/AssemblyInfo.cs b/MediaBrowser.Controller/Properties/AssemblyInfo.csindex 350165b1c6..63cc65d7aa 100644--- a/MediaBrowser.Controller/Properties/AssemblyInfo.cs+++ b/MediaBrowser.Controller/Properties/AssemblyInfo.cs@@ -1,5 +1,4 @@using System.Reflection;-using System.Runtime.CompilerServices;using System.Runtime.InteropServices;// General Information about an assembly is controlled through the followingdiff --git a/MediaBrowser.Controller/Providers/AudioInfoProvider.cs b/MediaBrowser.Controller/Providers/AudioInfoProvider.csindex 09cd80a210..f7242ce053 100644--- a/MediaBrowser.Controller/Providers/AudioInfoProvider.cs+++ b/MediaBrowser.Controller/Providers/AudioInfoProvider.cs@@ -26,9 +26,6 @@ namespace MediaBrowser.Controller.Providers{MediaStream stream = data.streams.First(s => s.codec_type.Equals("audio", StringComparison.OrdinalIgnoreCase));- string bitrate = null;- string duration = null;-audio.Channels = stream.channels;if (!string.IsNullOrEmpty(stream.sample_rate))@@ -36,8 +33,8 @@ namespace MediaBrowser.Controller.Providersaudio.SampleRate = int.Parse(stream.sample_rate);}- bitrate = stream.bit_rate;- duration = stream.duration;+ string bitrate = stream.bit_rate;+ string duration = stream.duration;if (string.IsNullOrEmpty(bitrate)){@@ -78,7 +75,7 @@ namespace MediaBrowser.Controller.Providersif (!string.IsNullOrEmpty(composer)){- audio.AddPerson(new PersonInfo() { Name = composer, Type = "Composer" });+ audio.AddPerson(new PersonInfo { Name = composer, Type = "Composer" });}audio.Album = GetDictionaryValue(tags, "album");diff --git a/MediaBrowser.Controller/Providers/BaseItemXmlParser.cs b/MediaBrowser.Controller/Providers/BaseItemXmlParser.csindex a3b0d2c600..837e4c3884 100644--- a/MediaBrowser.Controller/Providers/BaseItemXmlParser.cs+++ b/MediaBrowser.Controller/Providers/BaseItemXmlParser.cs@@ -62,7 +62,7 @@ namespace MediaBrowser.Controller.Providersitem.DisplayMediaType = VideoType.BluRay.ToString();break;case "dvd":- item.DisplayMediaType = VideoType.DVD.ToString();+ item.DisplayMediaType = VideoType.Dvd.ToString();break;case "":item.DisplayMediaType = null;@@ -163,7 +163,7 @@ namespace MediaBrowser.Controller.Providerscase "Director":{- foreach (PersonInfo p in GetSplitValues(reader.ReadElementContentAsString(), '|').Select(v => new PersonInfo() { Name = v, Type = "Director" }))+ foreach (PersonInfo p in GetSplitValues(reader.ReadElementContentAsString(), '|').Select(v => new PersonInfo { Name = v, Type = "Director" })){item.AddPerson(p);}@@ -171,7 +171,7 @@ namespace MediaBrowser.Controller.Providers}case "Writer":{- foreach (PersonInfo p in GetSplitValues(reader.ReadElementContentAsString(), '|').Select(v => new PersonInfo() { Name = v, Type = "Writer" }))+ foreach (PersonInfo p in GetSplitValues(reader.ReadElementContentAsString(), '|').Select(v => new PersonInfo { Name = v, Type = "Writer" })){item.AddPerson(p);}@@ -181,7 +181,7 @@ namespace MediaBrowser.Controller.Providerscase "Actors":case "GuestStars":{- foreach (PersonInfo p in GetSplitValues(reader.ReadElementContentAsString(), '|').Select(v => new PersonInfo() { Name = v, Type = "Actor" }))+ foreach (PersonInfo p in GetSplitValues(reader.ReadElementContentAsString(), '|').Select(v => new PersonInfo { Name = v, Type = "Actor" })){item.AddPerson(p);}diff --git a/MediaBrowser.Controller/Providers/ImageFromMediaLocationProvider.cs b/MediaBrowser.Controller/Providers/ImageFromMediaLocationProvider.csindex 6ccb6df7c1..f556d671e3 100644--- a/MediaBrowser.Controller/Providers/ImageFromMediaLocationProvider.cs+++ b/MediaBrowser.Controller/Providers/ImageFromMediaLocationProvider.cs@@ -34,10 +34,8 @@ namespace MediaBrowser.Controller.Providers{return Task.Run(() => { PopulateBaseItemImages(baseItem, args); });}- else- {- return Task.Run(() => { PopulateImages(item, args); });- }++ return Task.Run(() => { PopulateImages(item, args); });}return Task.FromResult<object>(null);diff --git a/MediaBrowser.Controller/Resolvers/Movies/MovieResolver.cs b/MediaBrowser.Controller/Resolvers/Movies/MovieResolver.csindex ae30a63872..a25968a943 100644--- a/MediaBrowser.Controller/Resolvers/Movies/MovieResolver.cs+++ b/MediaBrowser.Controller/Resolvers/Movies/MovieResolver.cs@@ -46,7 +46,7 @@ namespace MediaBrowser.Controller.Resolvers.Moviesprivate void SetProviderIdFromPath(Movie item){- string srch = "[tmdbid=";+ const string srch = "[tmdbid=";int index = item.Path.IndexOf(srch, System.StringComparison.OrdinalIgnoreCase);if (index != -1)diff --git a/MediaBrowser.Controller/Resolvers/TV/SeriesResolver.cs b/MediaBrowser.Controller/Resolvers/TV/SeriesResolver.csindex 3c43e460c5..b8ff2c37be 100644--- a/MediaBrowser.Controller/Resolvers/TV/SeriesResolver.cs+++ b/MediaBrowser.Controller/Resolvers/TV/SeriesResolver.cs@@ -48,8 +48,8 @@ namespace MediaBrowser.Controller.Resolvers.TVprivate void SetProviderIdFromPath(Series item){- string srch = "[tvdbid=";- int index = item.Path.IndexOf(srch, System.StringComparison.OrdinalIgnoreCase);+ const string srch = "[tvdbid=";+ int index = item.Path.IndexOf(srch, StringComparison.OrdinalIgnoreCase);if (index != -1){diff --git a/MediaBrowser.Controller/Resolvers/TV/TVUtils.cs b/MediaBrowser.Controller/Resolvers/TV/TVUtils.csindex ebfcda6028..c40f3fa63f 100644--- a/MediaBrowser.Controller/Resolvers/TV/TVUtils.cs+++ b/MediaBrowser.Controller/Resolvers/TV/TVUtils.cs@@ -9,7 +9,7 @@ namespace MediaBrowser.Controller.Resolvers.TV/// <summary>/// A season folder must contain one of these somewhere in the name/// </summary>- private static string[] SeasonFolderNames = new string[] {+ private static readonly string[] SeasonFolderNames = new string[] {"season","sæson","temporada",@@ -118,14 +118,12 @@ namespace MediaBrowser.Controller.Resolvers.TV{return true;}- else- {- nonSeriesFolders++;- if (nonSeriesFolders >= 3)- {- return false;- }+ nonSeriesFolders++;++ if (nonSeriesFolders >= 3)+ {+ return false;}}elsediff --git a/MediaBrowser.Controller/Resolvers/VideoResolver.cs b/MediaBrowser.Controller/Resolvers/VideoResolver.csindex 316c7798a1..e162fa509d 100644--- a/MediaBrowser.Controller/Resolvers/VideoResolver.cs+++ b/MediaBrowser.Controller/Resolvers/VideoResolver.cs@@ -33,7 +33,7 @@ namespace MediaBrowser.Controller.Resolvers{VideoType type = Path.GetExtension(args.Path).EndsWith("iso", System.StringComparison.OrdinalIgnoreCase) ? VideoType.Iso : VideoType.VideoFile;- return new T()+ return new T{VideoType = type,Path = args.Path@@ -77,15 +77,15 @@ namespace MediaBrowser.Controller.Resolvers{if (folder.IndexOf("video_ts", System.StringComparison.OrdinalIgnoreCase) != -1){- return new T()+ return new T{- VideoType = VideoType.DVD,+ VideoType = VideoType.Dvd,Path = Path.GetDirectoryName(folder)};}if (folder.IndexOf("bdmv", System.StringComparison.OrdinalIgnoreCase) != -1){- return new T()+ return new T{VideoType = VideoType.BluRay,Path = Path.GetDirectoryName(folder)diff --git a/MediaBrowser.Controller/ServerApplicationPaths.cs b/MediaBrowser.Controller/ServerApplicationPaths.csindex 0f4932fd04..f657ee259d 100644--- a/MediaBrowser.Controller/ServerApplicationPaths.cs+++ b/MediaBrowser.Controller/ServerApplicationPaths.cs@@ -153,7 +153,7 @@ namespace MediaBrowser.Controller}}- private string _CacheDirectory = null;+ private string _CacheDirectory;/// <summary>/// Gets the folder path to the cache directory/// </summary>@@ -175,7 +175,7 @@ namespace MediaBrowser.Controller}}- private string _FFProbeAudioCacheDirectory = null;+ private string _FFProbeAudioCacheDirectory;/// <summary>/// Gets the folder path to the ffprobe audio cache directory/// </summary>@@ -197,7 +197,7 @@ namespace MediaBrowser.Controller}}- private string _FFProbeVideoCacheDirectory = null;+ private string _FFProbeVideoCacheDirectory;/// <summary>/// Gets the folder path to the ffprobe video cache directory/// </summary>@@ -219,7 +219,7 @@ namespace MediaBrowser.Controller}}- private string _FFMpegDirectory = null;+ private string _FFMpegDirectory;/// <summary>/// Gets the folder path to ffmpeg/// </summary>@@ -241,7 +241,7 @@ namespace MediaBrowser.Controller}}- private string _FFMpegPath = null;+ private string _FFMpegPath;/// <summary>/// Gets the path to ffmpeg.exe/// </summary>@@ -258,7 +258,7 @@ namespace MediaBrowser.Controller}}- private string _FFProbePath = null;+ private string _FFProbePath;/// <summary>/// Gets the path to ffprobe.exe/// </summary>diff --git a/MediaBrowser.Controller/Weather/WeatherClient.cs b/MediaBrowser.Controller/Weather/WeatherClient.csindex c4abdc171e..a16244820c 100644--- a/MediaBrowser.Controller/Weather/WeatherClient.cs+++ b/MediaBrowser.Controller/Weather/WeatherClient.cs@@ -1,13 +1,13 @@-using System;+using MediaBrowser.Common.Logging;+using MediaBrowser.Common.Serialization;+using MediaBrowser.Model.Weather;+using System;using System.IO;using System.Linq;using System.Net;using System.Net.Cache;using System.Net.Http;using System.Threading.Tasks;-using MediaBrowser.Common.Logging;-using MediaBrowser.Common.Serialization;-using MediaBrowser.Model.Weather;namespace MediaBrowser.Controller.Weather{@@ -36,8 +36,8 @@ namespace MediaBrowser.Controller.Weatherreturn null;}- int numDays = 5;- string apiKey = "24902f60f1231941120109";+ const int numDays = 5;+ const string apiKey = "24902f60f1231941120109";string url = "http://free.worldweatheronline.com/feed/weather.ashx?q=" + zipCode + "&format=json&num_of_days=" + numDays + "&key=" + apiKey;@@ -95,7 +95,7 @@ namespace MediaBrowser.Controller.Weatherpublic WeatherStatus ToWeatherStatus(){- return new WeatherStatus()+ return new WeatherStatus{TemperatureCelsius = int.Parse(temp_C),TemperatureFahrenheit = int.Parse(temp_F),@@ -122,7 +122,7 @@ namespace MediaBrowser.Controller.Weatherpublic WeatherForecast ToWeatherForecast(){- return new WeatherForecast()+ return new WeatherForecast{Date = DateTime.Parse(date),HighTemperatureCelsius = int.Parse(tempMaxC),diff --git a/MediaBrowser.Controller/Xml/XmlExtensions.cs b/MediaBrowser.Controller/Xml/XmlExtensions.csindex e706baa614..d2e8e19832 100644--- a/MediaBrowser.Controller/Xml/XmlExtensions.cs+++ b/MediaBrowser.Controller/Xml/XmlExtensions.cs@@ -5,7 +5,7 @@ namespace MediaBrowser.Controller.Xml{public static class XmlExtensions{- private static CultureInfo _usCulture = new CultureInfo("en-US");+ private static readonly CultureInfo _usCulture = new CultureInfo("en-US");/// <summary>/// Reads a float from the current element of an XmlReaderdiff --git a/MediaBrowser.Model/DTO/DTOBaseItem.cs b/MediaBrowser.Model/DTO/DTOBaseItem.csindex 8d2cadd872..66049d3fd3 100644--- a/MediaBrowser.Model/DTO/DTOBaseItem.cs+++ b/MediaBrowser.Model/DTO/DTOBaseItem.cs@@ -10,7 +10,7 @@ namespace MediaBrowser.Model.DTO/// This holds information about a BaseItem in a format that is convenient for the client./// </summary>[ProtoContract]- public class DTOBaseItem : IHasProviderIds+ public class DtoBaseItem : IHasProviderIds{[ProtoMember(1)]public string Name { get; set; }@@ -91,7 +91,7 @@ namespace MediaBrowser.Model.DTOpublic int BackdropCount { get; set; }[ProtoMember(27)]- public DTOBaseItem[] Children { get; set; }+ public DtoBaseItem[] Children { get; set; }[ProtoMember(28)]public bool IsFolder { get; set; }@@ -136,7 +136,7 @@ namespace MediaBrowser.Model.DTOpublic int? ParentBackdropCount { get; set; }[ProtoMember(38)]- public DTOBaseItem[] LocalTrailers { get; set; }+ public DtoBaseItem[] LocalTrailers { get; set; }[ProtoMember(39)]public int LocalTrailerCount { get; set; }@@ -145,7 +145,7 @@ namespace MediaBrowser.Model.DTO/// User data for this item based on the user it's being requested for/// </summary>[ProtoMember(40)]- public DTOUserItemData UserData { get; set; }+ public DtoUserItemData UserData { get; set; }[ProtoMember(41)]public ItemSpecialCounts SpecialCounts { get; set; }diff --git a/MediaBrowser.Model/DTO/DTOUser.cs b/MediaBrowser.Model/DTO/DTOUser.csindex be13825f0b..766cd741ee 100644--- a/MediaBrowser.Model/DTO/DTOUser.cs+++ b/MediaBrowser.Model/DTO/DTOUser.cs@@ -1,11 +1,10 @@-using MediaBrowser.Model.Entities;-using ProtoBuf;+using ProtoBuf;using System;namespace MediaBrowser.Model.DTO{[ProtoContract]- public class DTOUser+ public class DtoUser{[ProtoMember(1)]public string Name { get; set; }diff --git a/MediaBrowser.Model/DTO/DTOUserItemData.cs b/MediaBrowser.Model/DTO/DTOUserItemData.csindex 33ff797afd..ce258f16f6 100644--- a/MediaBrowser.Model/DTO/DTOUserItemData.cs+++ b/MediaBrowser.Model/DTO/DTOUserItemData.cs@@ -3,7 +3,7 @@namespace MediaBrowser.Model.DTO{[ProtoContract]- public class DTOUserItemData+ public class DtoUserItemData{[ProtoMember(1)]public float? Rating { get; set; }diff --git a/MediaBrowser.Model/DTO/VideoOutputFormats.cs b/MediaBrowser.Model/DTO/VideoOutputFormats.csindex 3059f6acaf..c3840bff63 100644--- a/MediaBrowser.Model/DTO/VideoOutputFormats.cs+++ b/MediaBrowser.Model/DTO/VideoOutputFormats.cs@@ -9,12 +9,12 @@ namespace MediaBrowser.Model.DTO{Avi,Asf,- M4v,+ M4V,Mkv,Mov,Mp4,Ogv,- ThreeGP,+ ThreeGp,Ts,Webm,Wmvdiff --git a/MediaBrowser.Model/Entities/IHasProviderIds.cs b/MediaBrowser.Model/Entities/IHasProviderIds.csindex 8b9852dda3..96eb78f243 100644--- a/MediaBrowser.Model/Entities/IHasProviderIds.cs+++ b/MediaBrowser.Model/Entities/IHasProviderIds.cs@@ -10,7 +10,7 @@ namespace MediaBrowser.Model.EntitiesDictionary<string, string> ProviderIds { get; set; }}- public static class IProviderIdsExtensions+ public static class ProviderIdsExtensions{/// <summary>/// Gets a provider iddiff --git a/MediaBrowser.Model/Entities/VideoType.cs b/MediaBrowser.Model/Entities/VideoType.csindex 56308426e3..b30b146904 100644--- a/MediaBrowser.Model/Entities/VideoType.cs+++ b/MediaBrowser.Model/Entities/VideoType.cs@@ -5,7 +5,7 @@ namespace MediaBrowser.Model.Entities{VideoFile,Iso,- DVD,+ Dvd,BluRay}}diff --git a/MediaBrowser.Model/MediaBrowser.Model.csproj b/MediaBrowser.Model/MediaBrowser.Model.csprojindex 67d6dfd764..13d132601b 100644--- a/MediaBrowser.Model/MediaBrowser.Model.csproj+++ b/MediaBrowser.Model/MediaBrowser.Model.csproj@@ -36,12 +36,12 @@<Compile Include="Configuration\ServerConfiguration.cs" /><Compile Include="DTO\AudioInfo.cs" /><Compile Include="DTO\AudioOutputFormats.cs" />- <Compile Include="DTO\DTOUserItemData.cs" />+ <Compile Include="DTO\DtoUserItemData.cs" /><Compile Include="DTO\MovieInfo.cs" /><Compile Include="DTO\SeriesInfo.cs" /><Compile Include="Authentication\AuthenticationResult.cs" />- <Compile Include="DTO\DTOBaseItem.cs" />- <Compile Include="DTO\DTOUser.cs" />+ <Compile Include="DTO\DtoBaseItem.cs" />+ <Compile Include="DTO\DtoUser.cs" /><Compile Include="DTO\VideoInfo.cs" /><Compile Include="DTO\VideoOutputFormats.cs" /><Compile Include="DTO\IBNItem.cs" />diff --git a/MediaBrowser.Model/Plugins/BasePluginConfiguration.cs b/MediaBrowser.Model/Plugins/BasePluginConfiguration.csindex 55c5133a8e..e33ebcce78 100644--- a/MediaBrowser.Model/Plugins/BasePluginConfiguration.cs+++ b/MediaBrowser.Model/Plugins/BasePluginConfiguration.cs@@ -1,6 +1,4 @@-using System;-using System.Runtime.Serialization;-+namespace MediaBrowser.Model.Plugins{public class BasePluginConfigurationdiff --git a/MediaBrowser.Model/Properties/AssemblyInfo.cs b/MediaBrowser.Model/Properties/AssemblyInfo.csindex 6c64a5de60..a67dc993f2 100644--- a/MediaBrowser.Model/Properties/AssemblyInfo.cs+++ b/MediaBrowser.Model/Properties/AssemblyInfo.cs@@ -1,7 +1,5 @@-using System.Resources;-using System.Reflection;-using System.Runtime.CompilerServices;-using System.Runtime.InteropServices;+using System.Reflection;+using System.Resources;// General Information about an assembly is controlled through the following// set of attributes. Change these attribute values to modify the informationdiff --git a/MediaBrowser.ServerApplication/Properties/AssemblyInfo.cs b/MediaBrowser.ServerApplication/Properties/AssemblyInfo.csindex 09882706fd..35b3c6f98c 100644--- a/MediaBrowser.ServerApplication/Properties/AssemblyInfo.cs+++ b/MediaBrowser.ServerApplication/Properties/AssemblyInfo.cs@@ -1,6 +1,4 @@using System.Reflection;-using System.Resources;-using System.Runtime.CompilerServices;using System.Runtime.InteropServices;using System.Windows;diff --git a/MediaBrowser.WebDashboard/Properties/AssemblyInfo.cs b/MediaBrowser.WebDashboard/Properties/AssemblyInfo.csindex 17aca6c5cd..a33fd44622 100644--- a/MediaBrowser.WebDashboard/Properties/AssemblyInfo.cs+++ b/MediaBrowser.WebDashboard/Properties/AssemblyInfo.cs@@ -1,5 +1,4 @@using System.Reflection;-using System.Runtime.CompilerServices;using System.Runtime.InteropServices;// General Information about an assembly is controlled through the following