diff --git a/MediaBrowser.Api/ApiService.cs b/MediaBrowser.Api/ApiService.cs
index 88af0f8134..938a34f60c 100644
--- a/MediaBrowser.Api/ApiService.cs
+++ b/MediaBrowser.Api/ApiService.cs
@@ -3,7 +3,6 @@ using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Entities.Movies;
using MediaBrowser.Controller.Entities.TV;
using MediaBrowser.Model.DTO;
-using MediaBrowser.Model.Entities;
using System;
using System.Collections.Generic;
using System.Linq;
@@ -33,9 +32,9 @@ namespace MediaBrowser.Api
/// Whether or not to update the user's LastActivityDate
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
///
/// Converts a BaseItem to a DTOBaseItem
///
- public async static Task GetDTOBaseItem(BaseItem item, User user,
+ public async static Task GetDtoBaseItem(BaseItem item, User user,
bool includeChildren = true,
bool includePeople = true)
{
- DTOBaseItem dto = new DTOBaseItem();
+ DtoBaseItem dto = new DtoBaseItem();
List tasks = new List();
@@ -108,7 +107,7 @@ namespace MediaBrowser.Api
///
/// Sets simple property values on a DTOBaseItem
///
- 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
///
/// Attaches Studio DTO's to a DTOBaseItem
///
- 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(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
///
/// Attaches child DTO's to a DTOBaseItem
///
- 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 children = folder.GetParentalAllowedChildren(user);
- dto.Children = await Task.WhenAll(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);
}
}
///
/// Attaches trailer DTO's to a DTOBaseItem
///
- 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(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);
}
}
///
/// Attaches People DTO's to a DTOBaseItem
///
- 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 entities = await Task.WhenAll(item.People.Select(c => Kernel.Instance.ItemController.GetPerson(c.Key))).ConfigureAwait(false);
+ IEnumerable 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
///
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
///
/// Converts a User to a DTOUser
///
- 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
///
/// Converts a UserItemData to a DTOUserItemData
///
- public static DTOUserItemData GetDTOUserItemData(UserItemData data)
+ public static DtoUserItemData GetDtoUserItemData(UserItemData data)
{
if (data == null)
{
return null;
}
- return new DTOUserItemData()
+ return new DtoUserItemData
{
IsFavorite = data.IsFavorite,
Likes = data.Likes,
diff --git a/MediaBrowser.Api/HttpHandlers/AudioHandler.cs b/MediaBrowser.Api/HttpHandlers/AudioHandler.cs
index 3d17a3d6a2..9c16acd2ef 100644
--- a/MediaBrowser.Api/HttpHandlers/AudioHandler.cs
+++ b/MediaBrowser.Api/HttpHandlers/AudioHandler.cs
@@ -86,7 +86,7 @@ namespace MediaBrowser.Api.HttpHandlers
///
protected override string GetCommandLineArguments()
{
- List audioTranscodeParams = new List();
+ var audioTranscodeParams = new List();
AudioOutputFormats outputFormat = GetConversionOutputFormat();
diff --git a/MediaBrowser.Api/HttpHandlers/BaseMediaHandler.cs b/MediaBrowser.Api/HttpHandlers/BaseMediaHandler.cs
index e87af76ea5..32fdb7efa2 100644
--- a/MediaBrowser.Api/HttpHandlers/BaseMediaHandler.cs
+++ b/MediaBrowser.Api/HttpHandlers/BaseMediaHandler.cs
@@ -38,7 +38,7 @@ namespace MediaBrowser.Api.HttpHandlers
}
}
- private TBaseItemType _LibraryItem;
+ private TBaseItemType _libraryItem;
///
/// Gets the library item that will be played, if any
///
@@ -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 GetContentType()
{
- return Task.FromResult(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)
{
diff --git a/MediaBrowser.Api/HttpHandlers/FavoriteStatusHandler.cs b/MediaBrowser.Api/HttpHandlers/FavoriteStatusHandler.cs
index 4125b940f1..19c175d8b8 100644
--- a/MediaBrowser.Api/HttpHandlers/FavoriteStatusHandler.cs
+++ b/MediaBrowser.Api/HttpHandlers/FavoriteStatusHandler.cs
@@ -1,7 +1,6 @@
using MediaBrowser.Common.Net.Handlers;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Model.DTO;
-using MediaBrowser.Model.Entities;
using System.ComponentModel.Composition;
using System.Net;
using System.Threading.Tasks;
@@ -12,14 +11,14 @@ namespace MediaBrowser.Api.HttpHandlers
/// Provides a handler to set user favorite status for an item
///
[Export(typeof(BaseHandler))]
- public class FavoriteStatusHandler : BaseSerializationHandler
+ public class FavoriteStatusHandler : BaseSerializationHandler
{
public override bool HandlesRequest(HttpListenerRequest request)
{
return ApiService.IsApiUrlMatch("FavoriteStatus", request);
}
- protected override Task GetObjectToSerialize()
+ protected override Task 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(ApiService.GetDTOUserItemData(data));
+ return Task.FromResult(ApiService.GetDtoUserItemData(data));
}
}
}
\ No newline at end of file
diff --git a/MediaBrowser.Api/HttpHandlers/GenresHandler.cs b/MediaBrowser.Api/HttpHandlers/GenresHandler.cs
index 0ff48761ca..2694756dd3 100644
--- a/MediaBrowser.Api/HttpHandlers/GenresHandler.cs
+++ b/MediaBrowser.Api/HttpHandlers/GenresHandler.cs
@@ -60,7 +60,7 @@ namespace MediaBrowser.Api.HttpHandlers
}
// Get the Genre objects
- Genre[] entities = await Task.WhenAll(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];
diff --git a/MediaBrowser.Api/HttpHandlers/ImageHandler.cs b/MediaBrowser.Api/HttpHandlers/ImageHandler.cs
index c5949122fa..11246d4058 100644
--- a/MediaBrowser.Api/HttpHandlers/ImageHandler.cs
+++ b/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 GetImagePath()
{
- if (_ImagePath == null)
+ if (_imagePath == null)
{
- _ImagePath = await DiscoverImagePath();
+ _imagePath = await DiscoverImagePath();
}
- return _ImagePath;
+ return _imagePath;
}
private async Task DiscoverImagePath()
@@ -77,21 +77,21 @@ namespace MediaBrowser.Api.HttpHandlers
return GetImagePathFromTypes(item, ImageType, index);
}
- private Stream _SourceStream = null;
+ private Stream _sourceStream;
private async Task GetSourceStream()
{
await EnsureSourceStream().ConfigureAwait(false);
- return _SourceStream;
+ return _sourceStream;
}
- private bool _SourceStreamEnsured = false;
+ private bool _sourceStreamEnsured;
private async Task EnsureSourceStream()
{
- if (!_SourceStreamEnsured)
+ if (!_sourceStreamEnsured)
{
try
{
- _SourceStream = File.OpenRead(await GetImagePath().ConfigureAwait(false));
+ _sourceStream = File.OpenRead(await GetImagePath().ConfigureAwait(false));
}
catch (FileNotFoundException ex)
{
@@ -110,7 +110,7 @@ namespace MediaBrowser.Api.HttpHandlers
}
finally
{
- _SourceStreamEnsured = true;
+ _sourceStreamEnsured = true;
}
}
}
@@ -248,26 +248,24 @@ namespace MediaBrowser.Api.HttpHandlers
{
return item.LogoImagePath;
}
- else if (imageType == ImageType.Backdrop)
+ if (imageType == ImageType.Backdrop)
{
return item.BackdropImagePaths.ElementAt(imageIndex);
}
- else if (imageType == ImageType.Banner)
+ if (imageType == ImageType.Banner)
{
return item.BannerImagePath;
}
- else if (imageType == ImageType.Art)
+ if (imageType == ImageType.Art)
{
return item.ArtImagePath;
}
- else if (imageType == ImageType.Thumbnail)
+ if (imageType == ImageType.Thumbnail)
{
return item.ThumbnailImagePath;
}
- else
- {
- return item.PrimaryImagePath;
- }
+
+ return item.PrimaryImagePath;
}
}
}
diff --git a/MediaBrowser.Api/HttpHandlers/ItemHandler.cs b/MediaBrowser.Api/HttpHandlers/ItemHandler.cs
index 491f45446d..60b328d1a3 100644
--- a/MediaBrowser.Api/HttpHandlers/ItemHandler.cs
+++ b/MediaBrowser.Api/HttpHandlers/ItemHandler.cs
@@ -11,14 +11,14 @@ namespace MediaBrowser.Api.HttpHandlers
/// Provides a handler to retrieve a single item
///
[Export(typeof(BaseHandler))]
- public class ItemHandler : BaseSerializationHandler
+ public class ItemHandler : BaseSerializationHandler
{
public override bool HandlesRequest(HttpListenerRequest request)
{
return ApiService.IsApiUrlMatch("item", request);
}
- protected override Task GetObjectToSerialize()
+ protected override Task 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);
}
}
}
diff --git a/MediaBrowser.Api/HttpHandlers/ItemListHandler.cs b/MediaBrowser.Api/HttpHandlers/ItemListHandler.cs
index bce018d3ef..e4044b1d7b 100644
--- a/MediaBrowser.Api/HttpHandlers/ItemListHandler.cs
+++ b/MediaBrowser.Api/HttpHandlers/ItemListHandler.cs
@@ -11,20 +11,20 @@ using System.Threading.Tasks;
namespace MediaBrowser.Api.HttpHandlers
{
[Export(typeof(BaseHandler))]
- public class ItemListHandler : BaseSerializationHandler
+ public class ItemListHandler : BaseSerializationHandler
{
public override bool HandlesRequest(HttpListenerRequest request)
{
return ApiService.IsApiUrlMatch("itemlist", request);
}
- protected override Task GetObjectToSerialize()
+ protected override Task GetObjectToSerialize()
{
User user = ApiService.GetUserById(QueryString["userid"], true);
- return Task.WhenAll(GetItemsToSerialize(user).Select(i =>
+ return Task.WhenAll(GetItemsToSerialize(user).Select(i =>
{
- return ApiService.GetDTOBaseItem(i, user, includeChildren: false, includePeople: false);
+ return ApiService.GetDtoBaseItem(i, user, includeChildren: false, includePeople: false);
}));
}
@@ -36,31 +36,31 @@ namespace MediaBrowser.Api.HttpHandlers
{
return parent.GetInProgressItems(user);
}
- else if (ListType.Equals("recentlyaddeditems", StringComparison.OrdinalIgnoreCase))
+ if (ListType.Equals("recentlyaddeditems", StringComparison.OrdinalIgnoreCase))
{
return parent.GetRecentlyAddedItems(user);
}
- else if (ListType.Equals("recentlyaddedunplayeditems", StringComparison.OrdinalIgnoreCase))
+ if (ListType.Equals("recentlyaddedunplayeditems", StringComparison.OrdinalIgnoreCase))
{
return parent.GetRecentlyAddedUnplayedItems(user);
}
- else if (ListType.Equals("itemswithgenre", StringComparison.OrdinalIgnoreCase))
+ if (ListType.Equals("itemswithgenre", StringComparison.OrdinalIgnoreCase))
{
return parent.GetItemsWithGenre(QueryString["name"], user);
}
- else if (ListType.Equals("itemswithyear", StringComparison.OrdinalIgnoreCase))
+ if (ListType.Equals("itemswithyear", StringComparison.OrdinalIgnoreCase))
{
return parent.GetItemsWithYear(int.Parse(QueryString["year"]), user);
}
- else if (ListType.Equals("itemswithstudio", StringComparison.OrdinalIgnoreCase))
+ if (ListType.Equals("itemswithstudio", StringComparison.OrdinalIgnoreCase))
{
return parent.GetItemsWithStudio(QueryString["name"], user);
}
- else if (ListType.Equals("itemswithperson", StringComparison.OrdinalIgnoreCase))
+ if (ListType.Equals("itemswithperson", StringComparison.OrdinalIgnoreCase))
{
return parent.GetItemsWithPerson(QueryString["name"], null, user);
}
- else if (ListType.Equals("favorites", StringComparison.OrdinalIgnoreCase))
+ if (ListType.Equals("favorites", StringComparison.OrdinalIgnoreCase))
{
return parent.GetFavoriteItems(user);
}
diff --git a/MediaBrowser.Api/HttpHandlers/MovieSpecialFeaturesHandler.cs b/MediaBrowser.Api/HttpHandlers/MovieSpecialFeaturesHandler.cs
index 63426be47d..cfd75c8cfa 100644
--- a/MediaBrowser.Api/HttpHandlers/MovieSpecialFeaturesHandler.cs
+++ b/MediaBrowser.Api/HttpHandlers/MovieSpecialFeaturesHandler.cs
@@ -13,14 +13,14 @@ namespace MediaBrowser.Api.HttpHandlers
/// This handler retrieves special features for movies
///
[Export(typeof(BaseHandler))]
- public class MovieSpecialFeaturesHandler : BaseSerializationHandler
+ public class MovieSpecialFeaturesHandler : BaseSerializationHandler
{
public override bool HandlesRequest(HttpListenerRequest request)
{
return ApiService.IsApiUrlMatch("MovieSpecialFeatures", request);
}
- protected override Task GetObjectToSerialize()
+ protected override Task 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(new DTOBaseItem[] { });
+ return Task.FromResult(new DtoBaseItem[] { });
}
- return Task.WhenAll(movie.SpecialFeatures.Select(i =>
+ return Task.WhenAll(movie.SpecialFeatures.Select(i =>
{
- return ApiService.GetDTOBaseItem(i, user, includeChildren: false, includePeople: true);
+ return ApiService.GetDtoBaseItem(i, user, includeChildren: false);
}));
}
diff --git a/MediaBrowser.Api/HttpHandlers/PlayedStatusHandler.cs b/MediaBrowser.Api/HttpHandlers/PlayedStatusHandler.cs
index 4fe790c801..c010bcb023 100644
--- a/MediaBrowser.Api/HttpHandlers/PlayedStatusHandler.cs
+++ b/MediaBrowser.Api/HttpHandlers/PlayedStatusHandler.cs
@@ -1,7 +1,6 @@
using MediaBrowser.Common.Net.Handlers;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Model.DTO;
-using MediaBrowser.Model.Entities;
using System.ComponentModel.Composition;
using System.Net;
using System.Threading.Tasks;
@@ -12,14 +11,14 @@ namespace MediaBrowser.Api.HttpHandlers
/// Provides a handler to set played status for an item
///
[Export(typeof(BaseHandler))]
- public class PlayedStatusHandler : BaseSerializationHandler
+ public class PlayedStatusHandler : BaseSerializationHandler
{
public override bool HandlesRequest(HttpListenerRequest request)
{
return ApiService.IsApiUrlMatch("PlayedStatus", request);
}
- protected override Task GetObjectToSerialize()
+ protected override Task 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(ApiService.GetDTOUserItemData(data));
+ return Task.FromResult(ApiService.GetDtoUserItemData(data));
}
}
}
\ No newline at end of file
diff --git a/MediaBrowser.Api/HttpHandlers/PluginAssemblyHandler.cs b/MediaBrowser.Api/HttpHandlers/PluginAssemblyHandler.cs
index 07e6115a59..88161c1140 100644
--- a/MediaBrowser.Api/HttpHandlers/PluginAssemblyHandler.cs
+++ b/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);
}
}
}
diff --git a/MediaBrowser.Api/HttpHandlers/PluginConfigurationHandler.cs b/MediaBrowser.Api/HttpHandlers/PluginConfigurationHandler.cs
index 6dafd41707..95af9a3442 100644
--- a/MediaBrowser.Api/HttpHandlers/PluginConfigurationHandler.cs
+++ b/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 GetObjectToSerialize()
{
- return Task.FromResult(Plugin.Configuration);
+ return Task.FromResult(Plugin.Configuration);
}
public override TimeSpan CacheDuration
diff --git a/MediaBrowser.Api/HttpHandlers/PluginsHandler.cs b/MediaBrowser.Api/HttpHandlers/PluginsHandler.cs
index e90f322391..e9de0c476a 100644
--- a/MediaBrowser.Api/HttpHandlers/PluginsHandler.cs
+++ b/MediaBrowser.Api/HttpHandlers/PluginsHandler.cs
@@ -24,7 +24,7 @@ namespace MediaBrowser.Api.HttpHandlers
{
var plugins = Kernel.Instance.Plugins.Select(p =>
{
- return new PluginInfo()
+ return new PluginInfo
{
Name = p.Name,
Enabled = p.Enabled,
@@ -35,7 +35,7 @@ namespace MediaBrowser.Api.HttpHandlers
};
});
- return Task.FromResult>(plugins);
+ return Task.FromResult(plugins);
}
}
}
diff --git a/MediaBrowser.Api/HttpHandlers/ServerConfigurationHandler.cs b/MediaBrowser.Api/HttpHandlers/ServerConfigurationHandler.cs
index bbda31dc61..64ba44ec2f 100644
--- a/MediaBrowser.Api/HttpHandlers/ServerConfigurationHandler.cs
+++ b/MediaBrowser.Api/HttpHandlers/ServerConfigurationHandler.cs
@@ -19,7 +19,7 @@ namespace MediaBrowser.Api.HttpHandlers
protected override Task GetObjectToSerialize()
{
- return Task.FromResult(Kernel.Instance.Configuration);
+ return Task.FromResult(Kernel.Instance.Configuration);
}
public override TimeSpan CacheDuration
diff --git a/MediaBrowser.Api/HttpHandlers/StudiosHandler.cs b/MediaBrowser.Api/HttpHandlers/StudiosHandler.cs
index f80bed0896..86aa7c9c94 100644
--- a/MediaBrowser.Api/HttpHandlers/StudiosHandler.cs
+++ b/MediaBrowser.Api/HttpHandlers/StudiosHandler.cs
@@ -60,7 +60,7 @@ namespace MediaBrowser.Api.HttpHandlers
}
// Get the Studio objects
- Studio[] entities = await Task.WhenAll(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];
diff --git a/MediaBrowser.Api/HttpHandlers/UserHandler.cs b/MediaBrowser.Api/HttpHandlers/UserHandler.cs
index 5ccf3bb619..8b9e657661 100644
--- a/MediaBrowser.Api/HttpHandlers/UserHandler.cs
+++ b/MediaBrowser.Api/HttpHandlers/UserHandler.cs
@@ -8,22 +8,22 @@ using System.Threading.Tasks;
namespace MediaBrowser.Api.HttpHandlers
{
[Export(typeof(BaseHandler))]
- class UserHandler : BaseSerializationHandler
+ class UserHandler : BaseSerializationHandler
{
public override bool HandlesRequest(HttpListenerRequest request)
{
return ApiService.IsApiUrlMatch("user", request);
}
-
- protected override Task GetObjectToSerialize()
+
+ protected override Task 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(dto);
+ return Task.FromResult(dto);
}
}
}
diff --git a/MediaBrowser.Api/HttpHandlers/UserItemRatingHandler.cs b/MediaBrowser.Api/HttpHandlers/UserItemRatingHandler.cs
index d040414088..aed0804b6d 100644
--- a/MediaBrowser.Api/HttpHandlers/UserItemRatingHandler.cs
+++ b/MediaBrowser.Api/HttpHandlers/UserItemRatingHandler.cs
@@ -1,7 +1,6 @@
using MediaBrowser.Common.Net.Handlers;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Model.DTO;
-using MediaBrowser.Model.Entities;
using System.ComponentModel.Composition;
using System.Net;
using System.Threading.Tasks;
@@ -12,14 +11,14 @@ namespace MediaBrowser.Api.HttpHandlers
/// Provides a handler to set a user's rating for an item
///
[Export(typeof(BaseHandler))]
- public class UserItemRatingHandler : BaseSerializationHandler
+ public class UserItemRatingHandler : BaseSerializationHandler
{
public override bool HandlesRequest(HttpListenerRequest request)
{
return ApiService.IsApiUrlMatch("UserItemRating", request);
}
- protected override Task GetObjectToSerialize()
+ protected override Task 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(ApiService.GetDTOUserItemData(data));
+ return Task.FromResult(ApiService.GetDtoUserItemData(data));
}
}
}
\ No newline at end of file
diff --git a/MediaBrowser.Api/HttpHandlers/UsersHandler.cs b/MediaBrowser.Api/HttpHandlers/UsersHandler.cs
index 1451216bc6..3fc3a7d585 100644
--- a/MediaBrowser.Api/HttpHandlers/UsersHandler.cs
+++ b/MediaBrowser.Api/HttpHandlers/UsersHandler.cs
@@ -10,16 +10,16 @@ using System.Threading.Tasks;
namespace MediaBrowser.Api.HttpHandlers
{
[Export(typeof(BaseHandler))]
- class UsersHandler : BaseSerializationHandler>
+ class UsersHandler : BaseSerializationHandler>
{
public override bool HandlesRequest(HttpListenerRequest request)
{
return ApiService.IsApiUrlMatch("users", request);
}
- protected override Task> GetObjectToSerialize()
+ protected override Task> GetObjectToSerialize()
{
- return Task.FromResult>(Kernel.Instance.Users.Select(u => ApiService.GetDTOUser(u)));
+ return Task.FromResult(Kernel.Instance.Users.Select(u => ApiService.GetDtoUser(u)));
}
}
}
diff --git a/MediaBrowser.Api/HttpHandlers/VideoHandler.cs b/MediaBrowser.Api/HttpHandlers/VideoHandler.cs
index 4f8621ce7e..5e61127c6c 100644
--- a/MediaBrowser.Api/HttpHandlers/VideoHandler.cs
+++ b/MediaBrowser.Api/HttpHandlers/VideoHandler.cs
@@ -34,7 +34,7 @@ namespace MediaBrowser.Api.HttpHandlers
// mp4, 3gp, mov - muxer does not support non-seekable output
// avi, mov, mkv, m4v - can't stream these when encoding. the player will try to download them completely before starting playback.
// wmv - can't seem to figure out the output format name
- return new VideoOutputFormats[] { VideoOutputFormats.Mp4, VideoOutputFormats.ThreeGP, VideoOutputFormats.M4v, VideoOutputFormats.Mkv, VideoOutputFormats.Avi, VideoOutputFormats.Mov, VideoOutputFormats.Wmv };
+ return new VideoOutputFormats[] { VideoOutputFormats.Mp4, VideoOutputFormats.ThreeGp, VideoOutputFormats.M4V, VideoOutputFormats.Mkv, VideoOutputFormats.Avi, VideoOutputFormats.Mov, VideoOutputFormats.Wmv };
}
}
@@ -87,11 +87,11 @@ namespace MediaBrowser.Api.HttpHandlers
{
return "matroska";
}
- else if (outputFormat == VideoOutputFormats.Ts)
+ if (outputFormat == VideoOutputFormats.Ts)
{
return "mpegts";
}
- else if (outputFormat == VideoOutputFormats.Ogv)
+ if (outputFormat == VideoOutputFormats.Ogv)
{
return "ogg";
}
@@ -104,8 +104,6 @@ namespace MediaBrowser.Api.HttpHandlers
///
protected override string GetCommandLineArguments()
{
- List audioTranscodeParams = new List();
-
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;
diff --git a/MediaBrowser.Api/HttpHandlers/YearsHandler.cs b/MediaBrowser.Api/HttpHandlers/YearsHandler.cs
index c33464c4cc..a8c97294c4 100644
--- a/MediaBrowser.Api/HttpHandlers/YearsHandler.cs
+++ b/MediaBrowser.Api/HttpHandlers/YearsHandler.cs
@@ -57,7 +57,7 @@ namespace MediaBrowser.Api.HttpHandlers
}
// Get the Year objects
- Year[] entities = await Task.WhenAll(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];
diff --git a/MediaBrowser.Api/Properties/AssemblyInfo.cs b/MediaBrowser.Api/Properties/AssemblyInfo.cs
index bd747ea7da..c92346bac1 100644
--- a/MediaBrowser.Api/Properties/AssemblyInfo.cs
+++ b/MediaBrowser.Api/Properties/AssemblyInfo.cs
@@ -1,5 +1,4 @@
using System.Reflection;
-using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
diff --git a/MediaBrowser.ApiInteraction.Metro/DataSerializer.cs b/MediaBrowser.ApiInteraction.Metro/DataSerializer.cs
index d63e3f0213..92e3f7c2b7 100644
--- a/MediaBrowser.ApiInteraction.Metro/DataSerializer.cs
+++ b/MediaBrowser.ApiInteraction.Metro/DataSerializer.cs
@@ -12,7 +12,7 @@ namespace MediaBrowser.ApiInteraction
/// This means that this class can currently only handle types within the Model project.
/// If we need to, we can always add a param indicating whether or not the model serializer should be used.
///
- private static ProtobufModelSerializer ProtobufModelSerializer = new ProtobufModelSerializer();
+ private static readonly ProtobufModelSerializer ProtobufModelSerializer = new ProtobufModelSerializer();
public static T DeserializeFromStream(Stream stream, SerializationFormats format)
where T : class
diff --git a/MediaBrowser.ApiInteraction.Portable/ApiClient.cs b/MediaBrowser.ApiInteraction.Portable/ApiClient.cs
deleted file mode 100644
index b41572cd36..0000000000
--- a/MediaBrowser.ApiInteraction.Portable/ApiClient.cs
+++ /dev/null
@@ -1,585 +0,0 @@
-using MediaBrowser.Model.Authentication;
-using MediaBrowser.Model.Configuration;
-using MediaBrowser.Model.DTO;
-using MediaBrowser.Model.Weather;
-using System;
-using System.Collections.Generic;
-using System.IO;
-using System.Linq;
-using System.Net;
-using System.Text;
-
-namespace MediaBrowser.ApiInteraction.Portable
-{
- public class ApiClient : BaseApiClient
- {
- private HttpWebRequest GetNewRequest(string url)
- {
- return HttpWebRequest.CreateHttp(url);
- }
-
- ///
- /// Gets an image stream based on a url
- ///
- public void GetImageStreamAsync(string url, Action callback)
- {
- GetStreamAsync(url, callback);
- }
-
- ///
- /// Gets an image stream based on a url
- ///
- private void GetStreamAsync(string url, Action 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);
- }
-
- ///
- /// Gets a BaseItem
- ///
- public void GetItemAsync(Guid id, Guid userId, Action callback)
- {
- string url = ApiUrl + "/item?userId=" + userId.ToString();
-
- if (id != Guid.Empty)
- {
- url += "&id=" + id.ToString();
- }
-
- GetDataAsync(url, callback);
- }
-
- ///
- /// Gets all users
- ///
- public void GetAllUsersAsync(Action callback)
- {
- string url = ApiUrl + "/users";
-
- GetDataAsync(url, callback);
- }
-
- ///
- /// Gets all Genres
- ///
- public void GetAllGenresAsync(Guid userId, Action callback)
- {
- string url = ApiUrl + "/genres?userId=" + userId.ToString();
-
- GetDataAsync(url, callback);
- }
-
- ///
- /// Gets in-progress items
- ///
- /// The user id.
- /// (Optional) Specify a folder Id to localize the search to a specific folder.
- public void GetInProgressItemsItemsAsync(Guid userId, Action callback, Guid? folderId = null)
- {
- string url = ApiUrl + "/itemlist?listtype=inprogressitems&userId=" + userId.ToString();
-
- if (folderId.HasValue)
- {
- url += "&id=" + folderId.ToString();
- }
-
- GetDataAsync(url, callback);
- }
-
- ///
- /// Gets recently added items
- ///
- /// The user id.
- /// (Optional) Specify a folder Id to localize the search to a specific folder.
- public void GetRecentlyAddedItemsAsync(Guid userId, Action callback, Guid? folderId = null)
- {
- string url = ApiUrl + "/itemlist?listtype=recentlyaddeditems&userId=" + userId.ToString();
-
- if (folderId.HasValue)
- {
- url += "&id=" + folderId.ToString();
- }
-
- GetDataAsync(url, callback);
- }
-
- ///
- /// Gets favorite items
- ///
- /// The user id.
- /// (Optional) Specify a folder Id to localize the search to a specific folder.
- public void GetFavoriteItemsAsync(Guid userId, Action callback, Guid? folderId = null)
- {
- string url = ApiUrl + "/itemlist?listtype=favorites&userId=" + userId.ToString();
-
- if (folderId.HasValue)
- {
- url += "&id=" + folderId.ToString();
- }
-
- GetDataAsync(url, callback);
- }
-
- ///
- /// Gets recently added items that are unplayed.
- ///
- /// The user id.
- /// (Optional) Specify a folder Id to localize the search to a specific folder.
- public void GetRecentlyAddedUnplayedItemsAsync(Guid userId, Action callback, Guid? folderId = null)
- {
- string url = ApiUrl + "/itemlist?listtype=recentlyaddedunplayeditems&userId=" + userId.ToString();
-
- if (folderId.HasValue)
- {
- url += "&id=" + folderId.ToString();
- }
-
- GetDataAsync(url, callback);
- }
-
- ///
- /// Gets all Years
- ///
- public void GetAllYearsAsync(Guid userId, Action callback)
- {
- string url = ApiUrl + "/years?userId=" + userId.ToString();
-
- GetDataAsync(url, callback);
- }
-
- ///
- /// Gets all items that contain a given Year
- ///
- public void GetItemsWithYearAsync(string name, Guid userId, Action 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);
- }
-
- ///
- /// Gets all items that contain a given Genre
- ///
- public void GetItemsWithGenreAsync(string name, Guid userId, Action 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);
- }
-
- ///
- /// Gets all items that contain a given Person
- ///
- public void GetItemsWithPersonAsync(string name, Guid userId, Action 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);
- }
-
- ///
- /// Gets all items that contain a given Person
- ///
- public void GetItemsWithPersonAsync(string name, string personType, Guid userId, Action 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);
- }
-
- ///
- /// Gets all studious
- ///
- public void GetAllStudiosAsync(Guid userId, Action callback)
- {
- string url = ApiUrl + "/studios?userId=" + userId.ToString();
-
- GetDataAsync(url, callback);
- }
-
- ///
- /// Gets all items that contain a given Studio
- ///
- public void GetItemsWithStudioAsync(string name, Guid userId, Action 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);
- }
-
- ///
- /// Gets a studio
- ///
- public void GetStudioAsync(Guid userId, string name, Action callback)
- {
- string url = ApiUrl + "/studio?userId=" + userId.ToString() + "&name=" + name;
-
- GetDataAsync(url, callback);
- }
-
- ///
- /// Gets a genre
- ///
- public void GetGenreAsync(Guid userId, string name, Action callback)
- {
- string url = ApiUrl + "/genre?userId=" + userId.ToString() + "&name=" + name;
-
- GetDataAsync(url, callback);
- }
-
- ///
- /// Gets a person
- ///
- public void GetPersonAsync(Guid userId, string name, Action callback)
- {
- string url = ApiUrl + "/person?userId=" + userId.ToString() + "&name=" + name;
-
- GetDataAsync(url, callback);
- }
-
- ///
- /// Gets a year
- ///
- public void GetYearAsync(Guid userId, int year, Action callback)
- {
- string url = ApiUrl + "/year?userId=" + userId.ToString() + "&year=" + year;
-
- GetDataAsync(url, callback);
- }
-
- ///
- /// Gets a list of plugins installed on the server
- ///
- public void GetInstalledPluginsAsync(Action callback)
- {
- string url = ApiUrl + "/plugins";
-
- GetDataAsync(url, callback);
- }
-
- ///
- /// Gets a list of plugins installed on the server
- ///
- public void GetPluginAssemblyAsync(PluginInfo plugin, Action callback)
- {
- string url = ApiUrl + "/pluginassembly?assemblyfilename=" + plugin.AssemblyFileName;
-
- GetStreamAsync(url, callback);
- }
-
- ///
- /// Gets the current server configuration
- ///
- public void GetServerConfigurationAsync(Action callback)
- {
- string url = ApiUrl + "/ServerConfiguration";
-
- GetDataAsync(url, callback);
- }
-
- ///
- /// Gets weather information for the default location as set in configuration
- ///
- public void GetPluginConfigurationAsync(PluginInfo plugin, Type configurationType, Action