Browse Source

Some minor code cleanups

LukePulverenti Luke Pulverenti luke pulverenti 13 năm trước cách đây
mục cha
commit
670a53258e
80 tập tin đã thay đổi với 318 bổ sung1120 xóa
  1. 23 24
      MediaBrowser.Api/ApiService.cs
  2. 1 1
      MediaBrowser.Api/HttpHandlers/AudioHandler.cs
  3. 10 12
      MediaBrowser.Api/HttpHandlers/BaseMediaHandler.cs
  4. 3 4
      MediaBrowser.Api/HttpHandlers/FavoriteStatusHandler.cs
  5. 1 1
      MediaBrowser.Api/HttpHandlers/GenresHandler.cs
  6. 16 18
      MediaBrowser.Api/HttpHandlers/ImageHandler.cs
  7. 3 3
      MediaBrowser.Api/HttpHandlers/ItemHandler.cs
  8. 11 11
      MediaBrowser.Api/HttpHandlers/ItemListHandler.cs
  9. 5 5
      MediaBrowser.Api/HttpHandlers/MovieSpecialFeaturesHandler.cs
  10. 3 4
      MediaBrowser.Api/HttpHandlers/PlayedStatusHandler.cs
  11. 1 1
      MediaBrowser.Api/HttpHandlers/PluginAssemblyHandler.cs
  12. 5 5
      MediaBrowser.Api/HttpHandlers/PluginConfigurationHandler.cs
  13. 2 2
      MediaBrowser.Api/HttpHandlers/PluginsHandler.cs
  14. 1 1
      MediaBrowser.Api/HttpHandlers/ServerConfigurationHandler.cs
  15. 1 1
      MediaBrowser.Api/HttpHandlers/StudiosHandler.cs
  16. 5 5
      MediaBrowser.Api/HttpHandlers/UserHandler.cs
  17. 3 4
      MediaBrowser.Api/HttpHandlers/UserItemRatingHandler.cs
  18. 3 3
      MediaBrowser.Api/HttpHandlers/UsersHandler.cs
  19. 11 13
      MediaBrowser.Api/HttpHandlers/VideoHandler.cs
  20. 1 1
      MediaBrowser.Api/HttpHandlers/YearsHandler.cs
  21. 0 1
      MediaBrowser.Api/Properties/AssemblyInfo.cs
  22. 1 1
      MediaBrowser.ApiInteraction.Metro/DataSerializer.cs
  23. 0 585
      MediaBrowser.ApiInteraction.Portable/ApiClient.cs
  24. 0 72
      MediaBrowser.ApiInteraction.Portable/MediaBrowser.ApiInteraction.Portable.csproj
  25. 0 30
      MediaBrowser.ApiInteraction.Portable/Properties/AssemblyInfo.cs
  26. 0 6
      MediaBrowser.ApiInteraction.sln
  27. 2 2
      MediaBrowser.ApiInteraction/BaseApiClient.cs
  28. 36 36
      MediaBrowser.ApiInteraction/BaseHttpApiClient.cs
  29. 4 4
      MediaBrowser.ApiInteraction/DataSerializer.cs
  30. 0 1
      MediaBrowser.ApiInteraction/Properties/AssemblyInfo.cs
  31. 5 5
      MediaBrowser.Common/Kernel/BaseKernel.cs
  32. 1 1
      MediaBrowser.Common/Logging/BaseLogger.cs
  33. 1 3
      MediaBrowser.Common/Logging/LogRow.cs
  34. 8 4
      MediaBrowser.Common/Logging/StreamLogger.cs
  35. 0 73
      MediaBrowser.Common/Logging/ThreadedLogger.cs
  36. 0 1
      MediaBrowser.Common/MediaBrowser.Common.csproj
  37. 2 2
      MediaBrowser.Common/Net/Handlers/BaseEmbeddedResourceHandler.cs
  38. 6 5
      MediaBrowser.Common/Net/Handlers/BaseHandler.cs
  39. 12 12
      MediaBrowser.Common/Net/Handlers/BaseSerializationHandler.cs
  40. 10 14
      MediaBrowser.Common/Net/Handlers/StaticFileHandler.cs
  41. 1 1
      MediaBrowser.Common/Net/HttpServer.cs
  42. 32 32
      MediaBrowser.Common/Net/MimeTypes.cs
  43. 2 2
      MediaBrowser.Common/Plugins/BasePlugin.cs
  44. 0 1
      MediaBrowser.Common/Properties/AssemblyInfo.cs
  45. 3 3
      MediaBrowser.Common/Serialization/JsonSerializer.cs
  46. 2 2
      MediaBrowser.Common/Serialization/JsvSerializer.cs
  47. 2 2
      MediaBrowser.Common/Serialization/ProtobufSerializer.cs
  48. 1 1
      MediaBrowser.Common/Serialization/XmlSerializer.cs
  49. 2 2
      MediaBrowser.Common/UI/BaseApplication.cs
  50. 4 5
      MediaBrowser.Common/UI/SingleInstance.cs
  51. 2 2
      MediaBrowser.Common/UI/Splash.xaml.cs
  52. 1 1
      MediaBrowser.Controller/Entities/Folder.cs
  53. 1 1
      MediaBrowser.Controller/Entities/UserItemData.cs
  54. 1 1
      MediaBrowser.Controller/FFMpeg/FFProbe.cs
  55. 4 6
      MediaBrowser.Controller/IO/DirectoryWatchers.cs
  56. 1 1
      MediaBrowser.Controller/IO/FileData.cs
  57. 3 3
      MediaBrowser.Controller/Kernel.cs
  58. 5 7
      MediaBrowser.Controller/Library/ItemController.cs
  59. 0 1
      MediaBrowser.Controller/Properties/AssemblyInfo.cs
  60. 3 6
      MediaBrowser.Controller/Providers/AudioInfoProvider.cs
  61. 4 4
      MediaBrowser.Controller/Providers/BaseItemXmlParser.cs
  62. 2 4
      MediaBrowser.Controller/Providers/ImageFromMediaLocationProvider.cs
  63. 1 1
      MediaBrowser.Controller/Resolvers/Movies/MovieResolver.cs
  64. 2 2
      MediaBrowser.Controller/Resolvers/TV/SeriesResolver.cs
  65. 6 8
      MediaBrowser.Controller/Resolvers/TV/TVUtils.cs
  66. 4 4
      MediaBrowser.Controller/Resolvers/VideoResolver.cs
  67. 6 6
      MediaBrowser.Controller/ServerApplicationPaths.cs
  68. 8 8
      MediaBrowser.Controller/Weather/WeatherClient.cs
  69. 1 1
      MediaBrowser.Controller/Xml/XmlExtensions.cs
  70. 4 4
      MediaBrowser.Model/DTO/DTOBaseItem.cs
  71. 2 3
      MediaBrowser.Model/DTO/DTOUser.cs
  72. 1 1
      MediaBrowser.Model/DTO/DTOUserItemData.cs
  73. 2 2
      MediaBrowser.Model/DTO/VideoOutputFormats.cs
  74. 1 1
      MediaBrowser.Model/Entities/IHasProviderIds.cs
  75. 1 1
      MediaBrowser.Model/Entities/VideoType.cs
  76. 3 3
      MediaBrowser.Model/MediaBrowser.Model.csproj
  77. 1 3
      MediaBrowser.Model/Plugins/BasePluginConfiguration.cs
  78. 2 4
      MediaBrowser.Model/Properties/AssemblyInfo.cs
  79. 0 2
      MediaBrowser.ServerApplication/Properties/AssemblyInfo.cs
  80. 0 1
      MediaBrowser.WebDashboard/Properties/AssemblyInfo.cs

+ 23 - 24
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.Api
             dto.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.Api
 
             if (audio != null)
             {
-                dto.AudioInfo = new AudioInfo()
+                dto.AudioInfo = new AudioInfo
                 {
                     Album = audio.Album,
                     AlbumArtist = audio.AlbumArtist,
@@ -205,7 +204,7 @@ namespace MediaBrowser.Api
 
             if (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,

+ 1 - 1
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();
 

+ 10 - 12
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.HttpHandlers
 
         public 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.HttpHandlers
 
             if (!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.HttpHandlers
 
             process.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)
             {

+ 3 - 4
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 item
             BaseItem item = ApiService.GetItemById(QueryString["id"]);
@@ -33,7 +32,7 @@ namespace MediaBrowser.Api.HttpHandlers
             // Set favorite status
             data.IsFavorite = QueryString["isfavorite"] == "1";
 
-            return Task.FromResult<DTOUserItemData>(ApiService.GetDTOUserItemData(data));
+            return Task.FromResult(ApiService.GetDtoUserItemData(data));
         }
     }
 }

+ 1 - 1
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 IBNItem
             IBNItem[] items = new IBNItem[entities.Length];

+ 16 - 18
MediaBrowser.Api/HttpHandlers/ImageHandler.cs

@@ -21,15 +21,15 @@ namespace MediaBrowser.Api.HttpHandlers
             return 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.HttpHandlers
             return 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;
         }
     }
 }

+ 3 - 3
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.HttpHandlers
                 return null;
             }
 
-            return ApiService.GetDTOBaseItem(item, user);
+            return ApiService.GetDtoBaseItem(item, user);
         }
     }
 }

+ 11 - 11
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);
             }

+ 5 - 5
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 none
             if (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);
             }));
         }
 

+ 3 - 4
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 item
             BaseItem item = ApiService.GetItemById(QueryString["id"]);
@@ -33,7 +32,7 @@ namespace MediaBrowser.Api.HttpHandlers
 
             UserItemData data = item.GetUserData(user, true);
 
-            return Task.FromResult<DTOUserItemData>(ApiService.GetDTOUserItemData(data));
+            return Task.FromResult(ApiService.GetDtoUserItemData(data));
         }
     }
 }

+ 1 - 1
MediaBrowser.Api/HttpHandlers/PluginAssemblyHandler.cs

@@ -32,7 +32,7 @@ namespace MediaBrowser.Api.HttpHandlers
 
             string path = Path.Combine(Kernel.Instance.ApplicationPaths.PluginsPath, filename);
 
-            return new StaticFileHandler() { Path = path }.ProcessRequest(ctx);
+            return new StaticFileHandler { Path = path }.ProcessRequest(ctx);
         }
     }
 }

+ 5 - 5
MediaBrowser.Api/HttpHandlers/PluginConfigurationHandler.cs

@@ -18,25 +18,25 @@ namespace MediaBrowser.Api.HttpHandlers
             return 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 CacheDuration

+ 2 - 2
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);
         }
     }
 }

+ 1 - 1
MediaBrowser.Api/HttpHandlers/ServerConfigurationHandler.cs

@@ -19,7 +19,7 @@ namespace MediaBrowser.Api.HttpHandlers
         
         protected override Task<ServerConfiguration> GetObjectToSerialize()
         {
-            return Task.FromResult<ServerConfiguration>(Kernel.Instance.Configuration);
+            return Task.FromResult(Kernel.Instance.Configuration);
         }
 
         public override TimeSpan CacheDuration

+ 1 - 1
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 IBNItem
             IBNItem[] items = new IBNItem[entities.Length];

+ 5 - 5
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);
         }
     }
 }

+ 3 - 4
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 item
             BaseItem item = ApiService.GetItemById(QueryString["id"]);
@@ -41,7 +40,7 @@ namespace MediaBrowser.Api.HttpHandlers
                 data.Likes = QueryString["likes"] == "1";
             }
 
-            return Task.FromResult<DTOUserItemData>(ApiService.GetDTOUserItemData(data));
+            return Task.FromResult(ApiService.GetDtoUserItemData(data));
         }
     }
 }

+ 3 - 3
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)));
         }
     }
 }

+ 11 - 13
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 vpx
                 return "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.HttpHandlers
         private string GetAudioCodec(AudioStream audioStream, VideoOutputFormats outputFormat)
         {
             // Some output containers require specific codecs
-            
+
             if (outputFormat == VideoOutputFormats.Webm)
             {
                 // Per webm specification, it must be vorbis
                 return "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 output
                     return 2;
                 }
-                else if (audioCodec.Equals("wmav2"))
+                if (audioCodec.Equals("wmav2"))
                 {
                     // wmav2 currently only supports two channel output
                     return 2;

+ 1 - 1
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 IBNItem
             IBNItem[] items = new IBNItem[entities.Length];

+ 0 - 1
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 following 

+ 1 - 1
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 : class

+ 0 - 585
MediaBrowser.ApiInteraction.Portable/ApiClient.cs

@@ -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);
-        }
-    }
-}

+ 0 - 72
MediaBrowser.ApiInteraction.Portable/MediaBrowser.ApiInteraction.Portable.csproj

@@ -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>

+ 0 - 30
MediaBrowser.ApiInteraction.Portable/Properties/AssemblyInfo.cs

@@ -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")]

+ 0 - 6
MediaBrowser.ApiInteraction.sln

@@ -12,18 +12,12 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".nuget", ".nuget", "{F0E0E6
 EndProject
 Project("{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}"
-EndProject
 Global
 	GlobalSection(SolutionConfigurationPlatforms) = preSolution
 		Debug|Any CPU = Debug|Any CPU
 		Release|Any CPU = Release|Any CPU
 	EndGlobalSection
 	GlobalSection(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 CPU

+ 2 - 2
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;
 

+ 36 - 36
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.ApiInteraction
 
             using (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.ApiInteraction
 
             using (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.ApiInteraction
 
             using (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.ApiInteraction
 
             using (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.ApiInteraction
 
             using (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.ApiInteraction
 
             using (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.ApiInteraction
 
             using (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.ApiInteraction
 
             using (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.ApiInteraction
 
             using (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.ApiInteraction
 
             using (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.ApiInteraction
 
             using (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.ApiInteraction
 
             using (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.ApiInteraction
 
             using (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.ApiInteraction
 
             using (Stream stream = await GetSerializedStreamAsync(url).ConfigureAwait(false))
             {
-                return DeserializeFromStream<DTOUserItemData>(stream);
+                return DeserializeFromStream<DtoUserItemData>(stream);
             }
         }
 

+ 4 - 4
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.ApiInteraction
         public 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);
             }

+ 0 - 1
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 following 

+ 5 - 5
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.Kernel
 
             HttpServer = new HttpServer(HttpServerUrlPrefix);
 
-            HttpListener = HttpServer.Subscribe((ctx) =>
+            HttpListener = HttpServer.Subscribe(ctx =>
             {
                 BaseHandler handler = HttpHandlers.FirstOrDefault(h => h.HandlesRequest(ctx.Request));
 

+ 1 - 1
MediaBrowser.Common/Logging/BaseLogger.cs

@@ -67,7 +67,7 @@ namespace MediaBrowser.Common.Logging
 
             Thread currentThread = Thread.CurrentThread;
 
-            LogRow row = new LogRow()
+            LogRow row = new LogRow
             {
                 Severity = severity,
                 Message = message,

+ 1 - 3
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.Logging
 
         public override string ToString()
         {
-            List<string> data = new List<string>();
+            var data = new List<string>();
 
             data.Add(Time.ToString(TimePattern));
 

+ 8 - 4
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.Logging
             Stream = 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()

+ 0 - 73
MediaBrowser.Common/Logging/ThreadedLogger.cs

@@ -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();
-        }
-    }
-}

+ 0 - 1
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" />

+ 2 - 2
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.Handlers
 
         public override Task<string> GetContentType()
         {
-            return Task.FromResult<string>(MimeTypes.GetMimeType(ResourcePath));
+            return Task.FromResult(MimeTypes.GetMimeType(ResourcePath));
         }
 
         protected override Task WriteResponseToOutputStream(Stream stream)

+ 6 - 5
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.Handlers
                 if (!_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 data

+ 12 - 12
MediaBrowser.Common/Net/Handlers/BaseSerializationHandler.cs

@@ -15,7 +15,7 @@ namespace MediaBrowser.Common.Net.Handlers
 
                 if (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.Handlers
 
             switch (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;
             }
         }

+ 10 - 14
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.Handlers
                 value = 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 memory
                     return 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()

+ 1 - 1
MediaBrowser.Common/Net/HttpServer.cs

@@ -20,7 +20,7 @@ namespace MediaBrowser.Common.Net
         private IObservable<HttpListenerContext> ObservableHttpContext()
         {
             return Observable.Create<HttpListenerContext>(obs =>
-                                Observable.FromAsync<HttpListenerContext>(() => listener.GetContextAsync())
+                                Observable.FromAsync(() => listener.GetContextAsync())
                                           .Subscribe(obs))
                              .Repeat()
                              .Retry()

+ 32 - 32
MediaBrowser.Common/Net/MimeTypes.cs

@@ -9,7 +9,7 @@ namespace MediaBrowser.Common.Net
 
         public 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";
             }

+ 2 - 2
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>

+ 0 - 1
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 following 

+ 3 - 3
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.Serialization
 
             using (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.Serialization
             return ServiceStack.Text.JsonSerializer.DeserializeFromStream(type, stream);
         }
 
-        private static bool IsConfigured = false;
+        private static bool IsConfigured;
         private static void Configure()
         {
             if (!IsConfigured)

+ 2 - 2
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);
             }
         }
 

+ 2 - 2
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);
             }
         }
 

+ 1 - 1
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);
             }
         }
 

+ 2 - 2
MediaBrowser.Common/UI/BaseApplication.cs

@@ -19,7 +19,7 @@ namespace MediaBrowser.Common.UI
         protected 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.UI
                 Logger.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)

+ 4 - 5
MediaBrowser.Common/UI/SingleInstance.cs

@@ -13,18 +13,17 @@ namespace Microsoft.Shell
     using 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.Shell
             finally
             {
 
-                IntPtr p = _LocalFree(argv);
+                _LocalFree(argv);
                 // Otherwise LocalFree failed.
                 // Assert.AreEqual(IntPtr.Zero, p);
             }

+ 2 - 2
MediaBrowser.Common/UI/Splash.xaml.cs

@@ -27,8 +27,8 @@ namespace MediaBrowser.Common.UI
                 Logger.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)

+ 1 - 1
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);
 

+ 1 - 1
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>

+ 1 - 1
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)
                 {

+ 4 - 6
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)

+ 1 - 1
MediaBrowser.Controller/IO/FileData.cs

@@ -149,7 +149,7 @@ namespace MediaBrowser.Controller.IO
         private 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 characters

+ 3 - 3
MediaBrowser.Controller/Kernel.cs

@@ -93,13 +93,13 @@ namespace MediaBrowser.Controller
 
             await 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()

+ 5 - 7
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.Library
                 if (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.Library
                 resolvedShortcuts.InsertRange(0, returnArray);
                 return resolvedShortcuts.ToArray();
             }
-            else
-            {
-                return returnArray;
-            }
+
+            return returnArray;
         }
 
         /// <summary>
@@ -231,7 +229,7 @@ namespace MediaBrowser.Controller.Library
             return 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 item

+ 0 - 1
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 following 

+ 3 - 6
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.Providers
                 audio.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.Providers
 
             if (!string.IsNullOrEmpty(composer))
             {
-                audio.AddPerson(new PersonInfo() { Name = composer, Type = "Composer" });
+                audio.AddPerson(new PersonInfo { Name = composer, Type = "Composer" });
             }
 
             audio.Album = GetDictionaryValue(tags, "album");

+ 4 - 4
MediaBrowser.Controller/Providers/BaseItemXmlParser.cs

@@ -62,7 +62,7 @@ namespace MediaBrowser.Controller.Providers
                                 item.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.Providers
 
                 case "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.Providers
                 case "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);
                         }

+ 2 - 4
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);

+ 1 - 1
MediaBrowser.Controller/Resolvers/Movies/MovieResolver.cs

@@ -46,7 +46,7 @@ namespace MediaBrowser.Controller.Resolvers.Movies
 
         private void SetProviderIdFromPath(Movie item)
         {
-            string srch = "[tmdbid=";
+            const string srch = "[tmdbid=";
             int index = item.Path.IndexOf(srch, System.StringComparison.OrdinalIgnoreCase);
 
             if (index != -1)

+ 2 - 2
MediaBrowser.Controller/Resolvers/TV/SeriesResolver.cs

@@ -48,8 +48,8 @@ namespace MediaBrowser.Controller.Resolvers.TV
 
         private 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)
             {

+ 6 - 8
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;
                     }
                 }
                 else

+ 4 - 4
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)

+ 6 - 6
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>

+ 8 - 8
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.Weather
                 return 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.Weather
 
         public 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.Weather
 
         public WeatherForecast ToWeatherForecast()
         {
-            return new WeatherForecast()
+            return new WeatherForecast
             {
                 Date = DateTime.Parse(date),
                 HighTemperatureCelsius = int.Parse(tempMaxC),

+ 1 - 1
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 XmlReader

+ 4 - 4
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.DTO
         public 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.DTO
         public 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; }

+ 2 - 3
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; }

+ 1 - 1
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; }

+ 2 - 2
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,
         Wmv

+ 1 - 1
MediaBrowser.Model/Entities/IHasProviderIds.cs

@@ -10,7 +10,7 @@ namespace MediaBrowser.Model.Entities
         Dictionary<string, string> ProviderIds { get; set; }
     }
 
-    public static class IProviderIdsExtensions
+    public static class ProviderIdsExtensions
     {
         /// <summary>
         /// Gets a provider id

+ 1 - 1
MediaBrowser.Model/Entities/VideoType.cs

@@ -5,7 +5,7 @@ namespace MediaBrowser.Model.Entities
     {
         VideoFile,
         Iso,
-        DVD,
+        Dvd,
         BluRay
     }
 }

+ 3 - 3
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" />

+ 1 - 3
MediaBrowser.Model/Plugins/BasePluginConfiguration.cs

@@ -1,6 +1,4 @@
-using System;
-using System.Runtime.Serialization;
-
+
 namespace MediaBrowser.Model.Plugins
 {
     public class BasePluginConfiguration

+ 2 - 4
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 information

+ 0 - 2
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;
 

+ 0 - 1
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