Conflicts:
	MediaBrowser.ServerApplication/CorePlugins/MediaBrowser.Api.dll
	MediaBrowser.ServerApplication/CorePlugins/MediaBrowser.ApiInteraction.Javascript.dll
	MediaBrowser.ServerApplication/CorePlugins/MediaBrowser.Server.Sqlite.dll
	MediaBrowser.ServerApplication/CorePlugins/MediaBrowser.Server.WorldWeatherOnline.dll
	MediaBrowser.ServerApplication/CorePlugins/MediaBrowser.WebDashboard.dll
This commit is contained in:
LukePulverenti 2013-02-23 10:32:54 -05:00
commit 33ed929b52
159 changed files with 3573 additions and 3367 deletions

2
.gitignore vendored
View File

@ -32,6 +32,7 @@ local.properties
## Media Browser
#################
ProgramData*/
CorePlugins*/
ProgramData-Server*/
ProgramData-UI*/
@ -145,6 +146,7 @@ publish/
# NuGet Packages Directory
## TODO: If you have NuGet Package Restore enabled, uncomment the next line
packages/
dlls/
# Windows Azure Build Output
csx

12
MediaBrowser.Api/Api.cs Normal file
View File

@ -0,0 +1,12 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace MediaBrowser.Api
{
class Api
{
}
}

View File

@ -1,11 +1,9 @@
using MediaBrowser.Common.IO;
using MediaBrowser.Common.Net;
using MediaBrowser.Common.Net;
using MediaBrowser.Controller.IO;
using MediaBrowser.Model.IO;
using ServiceStack.ServiceHost;
using System;
using System.Collections.Generic;
using System.ComponentModel.Composition;
using System.Globalization;
using System.IO;
using System.Linq;
@ -59,7 +57,6 @@ namespace MediaBrowser.Api
/// <summary>
/// Class EnvironmentService
/// </summary>
[Export(typeof(IRestfulService))]
public class EnvironmentService : BaseRestService
{
/// <summary>

View File

@ -5,7 +5,6 @@ using MediaBrowser.Controller.Library;
using MediaBrowser.Model.Connectivity;
using MediaBrowser.Model.Dto;
using System;
using System.ComponentModel.Composition;
using System.Threading.Tasks;
namespace MediaBrowser.Api.HttpHandlers
@ -13,7 +12,6 @@ namespace MediaBrowser.Api.HttpHandlers
/// <summary>
/// Provides a handler to set played status for an item
/// </summary>
[Export(typeof(IHttpServerHandler))]
public class PlaybackCheckInHandler : BaseSerializationHandler<Kernel, UserItemDataDto>
{
/// <summary>

View File

@ -1,19 +1,17 @@
using MediaBrowser.Common.IO;
using MediaBrowser.Common.Net.Handlers;
using MediaBrowser.Common.Net.Handlers;
using MediaBrowser.Controller;
using MediaBrowser.Controller.Entities;
using System;
using System.ComponentModel.Composition;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using MediaBrowser.Controller.IO;
namespace MediaBrowser.Api.HttpHandlers
{
/// <summary>
/// Makes changes to the user's media library
/// </summary>
[Export(typeof(IHttpServerHandler))]
public class UpdateMediaLibraryHandler : BaseActionHandler<Kernel>
{
/// <summary>

View File

@ -6,7 +6,6 @@ using MediaBrowser.Controller.Library;
using MediaBrowser.Model.Entities;
using ServiceStack.ServiceHost;
using System;
using System.ComponentModel.Composition;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
@ -114,7 +113,6 @@ namespace MediaBrowser.Api.Images
/// <summary>
/// Class ImageService
/// </summary>
[Export(typeof(IRestfulService))]
public class ImageService : BaseRestService
{
/// <summary>

View File

@ -5,7 +5,6 @@ using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Library;
using MediaBrowser.Model.Entities;
using System;
using System.ComponentModel.Composition;
using System.IO;
using System.Threading;
using System.Threading.Tasks;
@ -15,7 +14,6 @@ namespace MediaBrowser.Api.Images
/// <summary>
/// Class UploadImageHandler
/// </summary>
[Export(typeof(IHttpServerHandler))]
class UploadImageHandler : BaseActionHandler<Kernel>
{
/// <summary>

View File

@ -1,5 +1,4 @@
using MediaBrowser.Common.Mef;
using MediaBrowser.Common.Net;
using MediaBrowser.Common.Net;
using MediaBrowser.Controller;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Library;
@ -8,7 +7,6 @@ using MediaBrowser.Model.Entities;
using ServiceStack.ServiceHost;
using System;
using System.Collections.Generic;
using System.ComponentModel.Composition;
using System.Linq;
namespace MediaBrowser.Api
@ -97,7 +95,6 @@ namespace MediaBrowser.Api
/// <summary>
/// Class LibraryService
/// </summary>
[Export(typeof(IRestfulService))]
public class LibraryService : BaseRestService
{
/// <summary>
@ -213,7 +210,7 @@ namespace MediaBrowser.Api
{
var kernel = (Kernel)Kernel;
var allTypes = kernel.Assemblies.SelectMany(MefUtils.GetTypes).Where(t => !t.IsAbstract && t.IsSubclassOf(typeof(BaseItem)));
var allTypes = kernel.AllTypes.Where(t => !t.IsAbstract && t.IsSubclassOf(typeof(BaseItem)));
if (request.HasInternetProvider)
{

View File

@ -5,7 +5,6 @@ using MediaBrowser.Model.Globalization;
using MoreLinq;
using ServiceStack.ServiceHost;
using System.Collections.Generic;
using System.ComponentModel.Composition;
using System.Globalization;
using System.Linq;
@ -38,7 +37,6 @@ namespace MediaBrowser.Api
/// <summary>
/// Class CulturesService
/// </summary>
[Export(typeof(IRestfulService))]
public class LocalizationService : BaseRestService
{
/// <summary>

View File

@ -64,7 +64,6 @@
<HintPath>..\packages\ServiceStack.Text.3.9.37\lib\net35\ServiceStack.Text.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.ComponentModel.Composition" />
<Reference Include="System.Core" />
<Reference Include="System.Drawing" />
<Reference Include="System.Runtime.Serialization" />

View File

@ -6,7 +6,6 @@ using MediaBrowser.Model.Updates;
using ServiceStack.ServiceHost;
using System;
using System.Collections.Generic;
using System.ComponentModel.Composition;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
@ -93,7 +92,6 @@ namespace MediaBrowser.Api
/// <summary>
/// Class PackageService
/// </summary>
[Export(typeof(IRestfulService))]
public class PackageService : BaseRestService
{
/// <summary>

View File

@ -3,7 +3,6 @@ using MediaBrowser.Model.Plugins;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.Composition;
using System.Diagnostics;
using System.Linq;
using System.Threading;
@ -14,7 +13,6 @@ namespace MediaBrowser.Api
/// <summary>
/// Class Plugin
/// </summary>
[Export(typeof(IPlugin))]
public class Plugin : BasePlugin<BasePluginConfiguration>
{
/// <summary>

View File

@ -7,10 +7,8 @@ using MediaBrowser.Model.Plugins;
using ServiceStack.ServiceHost;
using System;
using System.Collections.Generic;
using System.ComponentModel.Composition;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using ServiceStack.Text.Controller;
namespace MediaBrowser.Api
@ -119,7 +117,6 @@ namespace MediaBrowser.Api
/// <summary>
/// Class PluginsService
/// </summary>
[Export(typeof(IRestfulService))]
public class PluginService : BaseRestService
{
/// <summary>

View File

@ -6,7 +6,6 @@ using MediaBrowser.Model.Tasks;
using ServiceStack.ServiceHost;
using System;
using System.Collections.Generic;
using System.ComponentModel.Composition;
using System.IO;
using System.Linq;
using ServiceStack.Text.Controller;
@ -83,9 +82,19 @@ namespace MediaBrowser.Api.ScheduledTasks
/// <summary>
/// Class ScheduledTasksService
/// </summary>
[Export(typeof(IRestfulService))]
public class ScheduledTaskService : BaseRestService
{
/// <summary>
/// Gets or sets the task manager.
/// </summary>
/// <value>The task manager.</value>
private ITaskManager TaskManager { get; set; }
public ScheduledTaskService(ITaskManager taskManager)
{
TaskManager = taskManager;
}
/// <summary>
/// Gets the specified request.
/// </summary>
@ -93,7 +102,7 @@ namespace MediaBrowser.Api.ScheduledTasks
/// <returns>IEnumerable{TaskInfo}.</returns>
public object Get(GetScheduledTasks request)
{
var result = Kernel.ScheduledTasks.OrderBy(i => i.Name)
var result = TaskManager.ScheduledTasks.OrderBy(i => i.Name)
.Select(ScheduledTaskHelpers.GetTaskInfo).ToList();
return ToOptimizedResult(result);
@ -106,7 +115,7 @@ namespace MediaBrowser.Api.ScheduledTasks
/// <returns>IEnumerable{TaskInfo}.</returns>
public object Get(GetScheduledTask request)
{
var task = Kernel.ScheduledTasks.FirstOrDefault(i => i.Id == request.Id);
var task = TaskManager.ScheduledTasks.FirstOrDefault(i => i.Id == request.Id);
if (task == null)
{
@ -124,7 +133,7 @@ namespace MediaBrowser.Api.ScheduledTasks
/// <param name="request">The request.</param>
public void Post(StartScheduledTask request)
{
var task = Kernel.ScheduledTasks.FirstOrDefault(i => i.Id == request.Id);
var task = TaskManager.ScheduledTasks.FirstOrDefault(i => i.Id == request.Id);
if (task == null)
{
@ -140,7 +149,7 @@ namespace MediaBrowser.Api.ScheduledTasks
/// <param name="request">The request.</param>
public void Delete(StopScheduledTask request)
{
var task = Kernel.ScheduledTasks.FirstOrDefault(i => i.Id == request.Id);
var task = TaskManager.ScheduledTasks.FirstOrDefault(i => i.Id == request.Id);
if (task == null)
{
@ -160,8 +169,8 @@ namespace MediaBrowser.Api.ScheduledTasks
// https://code.google.com/p/servicestack/source/browse/trunk/Common/ServiceStack.Text/ServiceStack.Text/Controller/PathInfo.cs
var pathInfo = PathInfo.Parse(Request.PathInfo);
var id = new Guid(pathInfo.GetArgumentValue<string>(1));
var task = Kernel.ScheduledTasks.FirstOrDefault(i => i.Id == id);
var task = TaskManager.ScheduledTasks.FirstOrDefault(i => i.Id == id);
if (task == null)
{
@ -170,7 +179,7 @@ namespace MediaBrowser.Api.ScheduledTasks
var triggerInfos = JsonSerializer.DeserializeFromStream<TaskTriggerInfo[]>(request.RequestStream);
task.Triggers = triggerInfos.Select(t => ScheduledTaskHelpers.GetTrigger(t, Kernel));
task.Triggers = triggerInfos.Select(ScheduledTaskHelpers.GetTrigger);
}
}
}

View File

@ -1,10 +1,8 @@
using MediaBrowser.Common.Kernel;
using MediaBrowser.Common.ScheduledTasks;
using MediaBrowser.Controller;
using MediaBrowser.Model.Logging;
using MediaBrowser.Model.Tasks;
using System.Collections.Generic;
using System.ComponentModel.Composition;
using System.Linq;
using System.Threading.Tasks;
@ -13,9 +11,14 @@ namespace MediaBrowser.Api.ScheduledTasks
/// <summary>
/// Class ScheduledTasksWebSocketListener
/// </summary>
[Export(typeof(IWebSocketListener))]
public class ScheduledTasksWebSocketListener : BasePeriodicWebSocketListener<IEnumerable<TaskInfo>, object>
{
/// <summary>
/// Gets or sets the task manager.
/// </summary>
/// <value>The task manager.</value>
private ITaskManager TaskManager { get; set; }
/// <summary>
/// Gets the name.
/// </summary>
@ -33,13 +36,12 @@ namespace MediaBrowser.Api.ScheduledTasks
/// <summary>
/// Initializes a new instance of the <see cref="ScheduledTasksWebSocketListener" /> class.
/// </summary>
/// <param name="kernel">The kernel.</param>
/// <param name="logger">The logger.</param>
[ImportingConstructor]
public ScheduledTasksWebSocketListener([Import("kernel")] Kernel kernel, [Import("logger")] ILogger logger)
/// <param name="taskManager">The task manager.</param>
public ScheduledTasksWebSocketListener(ILogger logger, ITaskManager taskManager)
: base(logger)
{
_kernel = kernel;
TaskManager = taskManager;
}
/// <summary>
@ -49,7 +51,7 @@ namespace MediaBrowser.Api.ScheduledTasks
/// <returns>Task{IEnumerable{TaskInfo}}.</returns>
protected override Task<IEnumerable<TaskInfo>> GetDataToSend(object state)
{
return Task.FromResult(_kernel.ScheduledTasks.OrderBy(i => i.Name)
return Task.FromResult(TaskManager.ScheduledTasks.OrderBy(i => i.Name)
.Select(ScheduledTaskHelpers.GetTaskInfo));
}
}

View File

@ -5,7 +5,6 @@ using MediaBrowser.Controller.Resolvers;
using MediaBrowser.Model.Dto;
using System;
using System.Collections.Generic;
using System.ComponentModel.Composition;
using System.Linq;
using System.Net;
@ -14,7 +13,6 @@ namespace MediaBrowser.Api.Streaming
/// <summary>
/// Providers a progressive streaming audio api
/// </summary>
[Export(typeof(IHttpServerHandler))]
public class AudioHandler : BaseProgressiveStreamingHandler<Audio>
{
/// <summary>

View File

@ -859,11 +859,11 @@ namespace MediaBrowser.Api.Streaming
{
var video = LibraryItem as Video;
if (video != null && video.VideoType == VideoType.Iso &&
video.IsoType.HasValue && Kernel.IsoManager.CanMount(video.Path))
{
IsoMount = await Kernel.IsoManager.Mount(video.Path, CancellationToken.None).ConfigureAwait(false);
}
//if (video != null && video.VideoType == VideoType.Iso &&
// video.IsoType.HasValue && Kernel.IsoManager.CanMount(video.Path))
//{
// IsoMount = await Kernel.IsoManager.Mount(video.Path, CancellationToken.None).ConfigureAwait(false);
//}
var process = new Process
{

View File

@ -2,7 +2,6 @@
using MediaBrowser.Controller.Entities.Audio;
using MediaBrowser.Model.Dto;
using System;
using System.ComponentModel.Composition;
using System.Net;
namespace MediaBrowser.Api.Streaming
@ -10,7 +9,6 @@ namespace MediaBrowser.Api.Streaming
/// <summary>
/// Class HlsAudioPlaylistHandler
/// </summary>
[Export(typeof(IHttpServerHandler))]
public class HlsAudioPlaylistHandler : BaseHlsPlaylistHandler<Audio>
{
/// <summary>

View File

@ -1,7 +1,6 @@
using MediaBrowser.Common.Net.Handlers;
using MediaBrowser.Controller;
using System;
using System.ComponentModel.Composition;
using System.IO;
using System.Net;
using System.Threading.Tasks;
@ -11,7 +10,6 @@ namespace MediaBrowser.Api.Streaming
/// <summary>
/// Class HlsSegmentHandler
/// </summary>
[Export(typeof(IHttpServerHandler))]
public class HlsSegmentHandler : BaseHandler<Kernel>
{
/// <summary>

View File

@ -1,7 +1,6 @@
using MediaBrowser.Common.Net.Handlers;
using MediaBrowser.Controller.Entities;
using System;
using System.ComponentModel.Composition;
using System.Net;
namespace MediaBrowser.Api.Streaming
@ -9,7 +8,6 @@ namespace MediaBrowser.Api.Streaming
/// <summary>
/// Class HlsVideoPlaylistHandler
/// </summary>
[Export(typeof(IHttpServerHandler))]
public class HlsVideoPlaylistHandler : BaseHlsPlaylistHandler<Video>
{
/// <summary>

View File

@ -1,21 +1,15 @@
using System.IO;
using System.Threading;
using MediaBrowser.Common.IO;
using MediaBrowser.Common.Net.Handlers;
using MediaBrowser.Common.IO;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Resolvers;
using System;
using System.ComponentModel.Composition;
using System.Linq;
using System.Net;
using MediaBrowser.Model.Entities;
namespace MediaBrowser.Api.Streaming
{
/// <summary>
/// Providers a progressive streaming video api
/// </summary>
[Export(typeof(IHttpServerHandler))]
class VideoHandler : BaseProgressiveStreamingHandler<Video>
{
/// <summary>

View File

@ -5,7 +5,6 @@ using MediaBrowser.Controller;
using MediaBrowser.Model.Configuration;
using MediaBrowser.Model.System;
using ServiceStack.ServiceHost;
using System.ComponentModel.Composition;
using System.IO;
using System.Threading.Tasks;
@ -47,7 +46,6 @@ namespace MediaBrowser.Api
/// <summary>
/// Class SystemInfoService
/// </summary>
[Export(typeof(IRestfulService))]
public class SystemService : BaseRestService
{
/// <summary>

View File

@ -4,7 +4,6 @@ using MediaBrowser.Controller.Entities;
using ServiceStack.ServiceHost;
using System;
using System.Collections.Generic;
using System.ComponentModel.Composition;
using System.Linq;
using System.Threading.Tasks;
@ -22,7 +21,6 @@ namespace MediaBrowser.Api.UserLibrary
/// <summary>
/// Class GenresService
/// </summary>
[Export(typeof(IRestfulService))]
public class GenresService : BaseItemsByNameService<Genre>
{
/// <summary>

View File

@ -8,7 +8,6 @@ using MediaBrowser.Model.Entities;
using ServiceStack.ServiceHost;
using System;
using System.Collections.Generic;
using System.ComponentModel.Composition;
using System.Linq;
using System.Threading.Tasks;
@ -144,7 +143,6 @@ namespace MediaBrowser.Api.UserLibrary
/// <summary>
/// Class ItemsService
/// </summary>
[Export(typeof(IRestfulService))]
public class ItemsService : BaseRestService
{
/// <summary>

View File

@ -4,7 +4,6 @@ using MediaBrowser.Controller.Entities;
using ServiceStack.ServiceHost;
using System;
using System.Collections.Generic;
using System.ComponentModel.Composition;
using System.Linq;
using System.Threading.Tasks;
@ -27,7 +26,6 @@ namespace MediaBrowser.Api.UserLibrary
/// <summary>
/// Class PersonsService
/// </summary>
[Export(typeof(IRestfulService))]
public class PersonsService : BaseItemsByNameService<Person>
{
/// <summary>

View File

@ -1,10 +1,8 @@
using MediaBrowser.Common.Net;
using MediaBrowser.Controller;
using MediaBrowser.Controller;
using MediaBrowser.Controller.Entities;
using ServiceStack.ServiceHost;
using System;
using System.Collections.Generic;
using System.ComponentModel.Composition;
using System.Linq;
using System.Threading.Tasks;
@ -22,7 +20,6 @@ namespace MediaBrowser.Api.UserLibrary
/// <summary>
/// Class StudiosService
/// </summary>
[Export(typeof(IRestfulService))]
public class StudiosService : BaseItemsByNameService<Studio>
{
/// <summary>

View File

@ -9,7 +9,6 @@ using MediaBrowser.Model.Entities;
using ServiceStack.ServiceHost;
using System;
using System.Collections.Generic;
using System.ComponentModel.Composition;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
@ -252,7 +251,6 @@ namespace MediaBrowser.Api.UserLibrary
/// <summary>
/// Class UserLibraryService
/// </summary>
[Export(typeof(IRestfulService))]
public class UserLibraryService : BaseRestService
{
public object Get(GetSpecialFeatures request)

View File

@ -4,7 +4,6 @@ using MediaBrowser.Controller.Entities;
using ServiceStack.ServiceHost;
using System;
using System.Collections.Generic;
using System.ComponentModel.Composition;
using System.Globalization;
using System.Linq;
using System.Threading.Tasks;
@ -23,7 +22,6 @@ namespace MediaBrowser.Api.UserLibrary
/// <summary>
/// Class YearsService
/// </summary>
[Export(typeof(IRestfulService))]
public class YearsService : BaseItemsByNameService<Year>
{
/// <summary>

View File

@ -7,7 +7,6 @@ using MediaBrowser.Model.Dto;
using ServiceStack.ServiceHost;
using System;
using System.Collections.Generic;
using System.ComponentModel.Composition;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
@ -134,7 +133,6 @@ namespace MediaBrowser.Api
/// <summary>
/// Class UsersService
/// </summary>
[Export(typeof(IRestfulService))]
public class UserService : BaseRestService
{
/// <summary>

View File

@ -2,7 +2,6 @@
using MediaBrowser.Controller;
using MediaBrowser.Model.Weather;
using ServiceStack.ServiceHost;
using System.ComponentModel.Composition;
using System.Linq;
using System.Threading;
@ -24,7 +23,6 @@ namespace MediaBrowser.Api
/// <summary>
/// Class WeatherService
/// </summary>
[Export(typeof(IRestfulService))]
public class WeatherService : BaseRestService
{
/// <summary>

View File

@ -4,7 +4,6 @@ using MediaBrowser.Controller;
using MediaBrowser.Model.Logging;
using System;
using System.Collections.Generic;
using System.ComponentModel.Composition;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
@ -14,7 +13,6 @@ namespace MediaBrowser.Api.WebSocket
/// <summary>
/// Class ScheduledTasksWebSocketListener
/// </summary>
[Export(typeof(IWebSocketListener))]
public class LogFileWebSocketListener : BasePeriodicWebSocketListener<IEnumerable<string>, LogFileWebSocketState>
{
/// <summary>
@ -36,8 +34,7 @@ namespace MediaBrowser.Api.WebSocket
/// </summary>
/// <param name="logger">The logger.</param>
/// <param name="kernel">The kernel.</param>
[ImportingConstructor]
public LogFileWebSocketListener([Import("logger")] ILogger logger, [Import("kernel")] Kernel kernel)
public LogFileWebSocketListener(ILogger logger, Kernel kernel)
: base(logger)
{
_kernel = kernel;

View File

@ -2,7 +2,6 @@
using MediaBrowser.Controller;
using MediaBrowser.Model.Logging;
using MediaBrowser.Model.System;
using System.ComponentModel.Composition;
using System.Threading.Tasks;
namespace MediaBrowser.Api.WebSocket
@ -10,7 +9,6 @@ namespace MediaBrowser.Api.WebSocket
/// <summary>
/// Class SystemInfoWebSocketListener
/// </summary>
[Export(typeof(IWebSocketListener))]
public class SystemInfoWebSocketListener : BasePeriodicWebSocketListener<SystemInfo, object>
{
/// <summary>
@ -32,8 +30,7 @@ namespace MediaBrowser.Api.WebSocket
/// </summary>
/// <param name="kernel">The kernel.</param>
/// <param name="logger">The logger.</param>
[ImportingConstructor]
public SystemInfoWebSocketListener([Import("kernel")] Kernel kernel, [Import("logger")] ILogger logger)
public SystemInfoWebSocketListener(Kernel kernel, ILogger logger)
: base(logger)
{
_kernel = kernel;

View File

@ -2,7 +2,6 @@
using MediaBrowser.Common.Net;
using ServiceStack.ServiceHost;
using System;
using System.ComponentModel.Composition;
using System.IO;
using System.Threading.Tasks;
@ -25,7 +24,6 @@ namespace MediaBrowser.ApiInteraction.Javascript
/// <summary>
/// Class JavascriptApiClientService
/// </summary>
[Export(typeof(IRestfulService))]
public class JavascriptApiClientService : BaseRestService
{
/// <summary>

View File

@ -68,7 +68,6 @@
<HintPath>..\packages\ServiceStack.Text.3.9.37\lib\net35\ServiceStack.Text.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.ComponentModel.Composition" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />

View File

@ -98,6 +98,9 @@
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\Portable\$(TargetFrameworkVersion)\Microsoft.Portable.CSharp.targets" />
<Import Project="$(SolutionDir)\.nuget\nuget.targets" />
<Import Project="..\packages\Microsoft.Bcl.Build.1.0.0-rc\tools\Microsoft.Bcl.Build.targets" />
<PropertyGroup>
<PostBuildEvent>xcopy "$(TargetPath)" "$(SolutionDir)\Nuget\dlls\" /y /d /r /i</PostBuildEvent>
</PropertyGroup>
<!-- 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">

View File

@ -656,7 +656,7 @@ namespace MediaBrowser.ApiInteraction
/// </summary>
/// <param name="itemId">The item id.</param>
/// <param name="userId">The user id.</param>
/// <returns>Task{DtoUserItemData}.</returns>
/// <returns>Task{UserItemDataDto}.</returns>
/// <exception cref="System.ArgumentNullException">itemId</exception>
public Task<UserItemDataDto> ReportPlaybackStartAsync(string itemId, Guid userId)
{
@ -686,7 +686,7 @@ namespace MediaBrowser.ApiInteraction
/// <param name="itemId">The item id.</param>
/// <param name="userId">The user id.</param>
/// <param name="positionTicks">The position ticks.</param>
/// <returns>Task{DtoUserItemData}.</returns>
/// <returns>Task{UserItemDataDto}.</returns>
/// <exception cref="System.ArgumentNullException">itemId</exception>
public Task<UserItemDataDto> ReportPlaybackProgressAsync(string itemId, Guid userId, long? positionTicks)
{
@ -718,7 +718,7 @@ namespace MediaBrowser.ApiInteraction
/// <param name="itemId">The item id.</param>
/// <param name="userId">The user id.</param>
/// <param name="positionTicks">The position ticks.</param>
/// <returns>Task{DtoUserItemData}.</returns>
/// <returns>Task{UserItemDataDto}.</returns>
/// <exception cref="System.ArgumentNullException">itemId</exception>
public Task<UserItemDataDto> ReportPlaybackStoppedAsync(string itemId, Guid userId, long? positionTicks)
{
@ -749,7 +749,7 @@ namespace MediaBrowser.ApiInteraction
/// </summary>
/// <param name="itemId">The item id.</param>
/// <param name="userId">The user id.</param>
/// <returns>Task{DtoUserItemData}.</returns>
/// <returns>Task{UserItemDataDto}.</returns>
/// <exception cref="System.ArgumentNullException">itemId</exception>
public Task ClearUserItemRatingAsync(string itemId, Guid userId)
{
@ -774,7 +774,7 @@ namespace MediaBrowser.ApiInteraction
/// <param name="itemId">The item id.</param>
/// <param name="userId">The user id.</param>
/// <param name="likes">if set to <c>true</c> [likes].</param>
/// <returns>Task{DtoUserItemData}.</returns>
/// <returns>Task{UserItemDataDto}.</returns>
/// <exception cref="System.ArgumentNullException">itemId</exception>
public Task<UserItemDataDto> UpdateUserItemRatingAsync(string itemId, Guid userId, bool likes)
{

View File

@ -75,6 +75,9 @@
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="$(SolutionDir)\.nuget\nuget.targets" />
<PropertyGroup>
<PostBuildEvent>xcopy "$(TargetPath)" "$(SolutionDir)\Nuget\dlls\" /y /d /r /i</PostBuildEvent>
</PropertyGroup>
<!-- 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">

View File

@ -1,7 +1,5 @@
using MediaBrowser.Common.Events;
using MediaBrowser.Common.IO;
using MediaBrowser.Common.Localization;
using MediaBrowser.Common.Mef;
using MediaBrowser.Common.Net;
using MediaBrowser.Common.Plugins;
using MediaBrowser.Common.ScheduledTasks;
@ -11,8 +9,6 @@ using MediaBrowser.Model.Logging;
using MediaBrowser.Model.System;
using System;
using System.Collections.Generic;
using System.ComponentModel.Composition;
using System.ComponentModel.Composition.Hosting;
using System.Diagnostics;
using System.IO;
using System.Linq;
@ -183,36 +179,14 @@ namespace MediaBrowser.Common.Kernel
/// Gets the list of currently loaded plugins
/// </summary>
/// <value>The plugins.</value>
[ImportMany(typeof(IPlugin))]
public IEnumerable<IPlugin> Plugins { get; protected set; }
/// <summary>
/// Gets the list of Scheduled Tasks
/// </summary>
/// <value>The scheduled tasks.</value>
[ImportMany(typeof(IScheduledTask))]
public IEnumerable<IScheduledTask> ScheduledTasks { get; private set; }
/// <summary>
/// Gets the web socket listeners.
/// </summary>
/// <value>The web socket listeners.</value>
[ImportMany(typeof(IWebSocketListener))]
public IEnumerable<IWebSocketListener> WebSocketListeners { get; private set; }
/// <summary>
/// Gets the list of Localized string files
/// </summary>
/// <value>The string files.</value>
[ImportMany(typeof(LocalizedStringData))]
public IEnumerable<LocalizedStringData> StringFiles { get; private set; }
/// <summary>
/// Gets the MEF CompositionContainer
/// </summary>
/// <value>The composition container.</value>
private CompositionContainer CompositionContainer { get; set; }
/// <summary>
/// The _HTTP manager
/// </summary>
@ -225,25 +199,17 @@ namespace MediaBrowser.Common.Kernel
/// <value>The TCP manager.</value>
public TcpManager TcpManager { get; private set; }
/// <summary>
/// Gets the task manager.
/// </summary>
/// <value>The task manager.</value>
public TaskManager TaskManager { get; private set; }
/// <summary>
/// Gets the iso manager.
/// </summary>
/// <value>The iso manager.</value>
public IIsoManager IsoManager { get; private set; }
/// <summary>
/// Gets the rest services.
/// </summary>
/// <value>The rest services.</value>
[ImportMany(typeof(IRestfulService))]
public IEnumerable<IRestfulService> RestServices { get; private set; }
/// <summary>
/// The disposable parts
/// </summary>
private readonly List<IDisposable> _disposableParts = new List<IDisposable>();
/// <summary>
/// The _protobuf serializer initialized
/// </summary>
@ -265,7 +231,7 @@ namespace MediaBrowser.Common.Kernel
get
{
// Lazy load
LazyInitializer.EnsureInitialized(ref _protobufSerializer, ref _protobufSerializerInitialized, ref _protobufSerializerSyncLock, () => DynamicProtobufSerializer.Create(Assemblies));
LazyInitializer.EnsureInitialized(ref _protobufSerializer, ref _protobufSerializerInitialized, ref _protobufSerializerSyncLock, () => DynamicProtobufSerializer.Create(AllTypes));
return _protobufSerializer;
}
private set
@ -335,30 +301,36 @@ namespace MediaBrowser.Common.Kernel
/// <value>The application host.</value>
protected IApplicationHost ApplicationHost { get; private set; }
/// <summary>
/// Gets or sets the task manager.
/// </summary>
/// <value>The task manager.</value>
protected ITaskManager TaskManager { get; set; }
/// <summary>
/// Gets the assemblies.
/// </summary>
/// <value>The assemblies.</value>
public Assembly[] Assemblies { get; private set; }
protected Assembly[] Assemblies { get; private set; }
/// <summary>
/// Gets all types.
/// </summary>
/// <value>All types.</value>
public Type[] AllTypes { get; private set; }
/// <summary>
/// Initializes a new instance of the <see cref="BaseKernel{TApplicationPathsType}" /> class.
/// </summary>
/// <param name="appHost">The app host.</param>
/// <param name="isoManager">The iso manager.</param>
/// <param name="logger">The logger.</param>
/// <exception cref="System.ArgumentNullException">isoManager</exception>
protected BaseKernel(IApplicationHost appHost, IIsoManager isoManager, ILogger logger)
protected BaseKernel(IApplicationHost appHost, ILogger logger)
{
if (appHost == null)
{
throw new ArgumentNullException("appHost");
}
if (isoManager == null)
{
throw new ArgumentNullException("isoManager");
}
if (logger == null)
{
@ -366,7 +338,6 @@ namespace MediaBrowser.Common.Kernel
}
ApplicationHost = appHost;
IsoManager = isoManager;
Logger = logger;
}
@ -419,7 +390,7 @@ namespace MediaBrowser.Common.Kernel
await OnConfigurationLoaded().ConfigureAwait(false);
DisposeTaskManager();
TaskManager = new TaskManager(this, Logger);
TaskManager = new TaskManager(Logger);
Logger.Info("Loading Plugins");
await ReloadComposableParts().ConfigureAwait(false);
@ -460,25 +431,82 @@ namespace MediaBrowser.Common.Kernel
Assemblies = GetComposablePartAssemblies().ToArray();
CompositionContainer = MefUtils.GetSafeCompositionContainer(Assemblies.Select(i => new AssemblyCatalog(i)));
AllTypes = Assemblies.SelectMany(GetTypes).ToArray();
ComposeExportedValues(CompositionContainer);
CompositionContainer.ComposeParts(this);
ComposeParts(AllTypes);
await OnComposablePartsLoaded().ConfigureAwait(false);
}
CompositionContainer.Catalog.Dispose();
/// <summary>
/// Composes the parts.
/// </summary>
/// <param name="allTypes">All types.</param>
private void ComposeParts(IEnumerable<Type> allTypes)
{
var concreteTypes = allTypes.Where(t => t.IsClass && !t.IsAbstract && !t.IsInterface && !t.IsGenericType).ToArray();
RegisterExportedValues();
FindParts(concreteTypes);
}
/// <summary>
/// Composes the parts with ioc container.
/// </summary>
/// <param name="allTypes">All types.</param>
protected virtual void FindParts(Type[] allTypes)
{
RestServices = GetExports<IRestfulService>(allTypes);
WebSocketListeners = GetExports<IWebSocketListener>(allTypes);
Plugins = GetExports<IPlugin>(allTypes);
var tasks = GetExports<IScheduledTask>(allTypes, false);
TaskManager.AddTasks(tasks);
}
/// <summary>
/// Gets the exports.
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="allTypes">All types.</param>
/// <param name="manageLiftime">if set to <c>true</c> [manage liftime].</param>
/// <returns>IEnumerable{``0}.</returns>
protected IEnumerable<T> GetExports<T>(Type[] allTypes, bool manageLiftime = true)
{
var currentType = typeof(T);
Logger.Info("Composing instances of " + currentType.Name);
var parts = allTypes.Where(currentType.IsAssignableFrom).Select(Instantiate).Cast<T>().ToArray();
if (manageLiftime)
{
_disposableParts.AddRange(parts.OfType<IDisposable>());
}
return parts;
}
/// <summary>
/// Instantiates the specified type.
/// </summary>
/// <param name="type">The type.</param>
/// <returns>System.Object.</returns>
private object Instantiate(Type type)
{
return ApplicationHost.CreateInstance(type);
}
/// <summary>
/// Composes the exported values.
/// </summary>
/// <param name="container">The container.</param>
protected virtual void ComposeExportedValues(CompositionContainer container)
protected virtual void RegisterExportedValues()
{
container.ComposeExportedValue("logger", Logger);
container.ComposeExportedValue("appHost", ApplicationHost);
ApplicationHost.Register<IKernel>(this);
ApplicationHost.Register(TaskManager);
}
/// <summary>
@ -545,6 +573,31 @@ namespace MediaBrowser.Common.Kernel
yield return GetType().Assembly;
}
/// <summary>
/// Gets a list of types within an assembly
/// This will handle situations that would normally throw an exception - such as a type within the assembly that depends on some other non-existant reference
/// </summary>
/// <param name="assembly">The assembly.</param>
/// <returns>IEnumerable{Type}.</returns>
/// <exception cref="System.ArgumentNullException">assembly</exception>
private static IEnumerable<Type> GetTypes(Assembly assembly)
{
if (assembly == null)
{
throw new ArgumentNullException("assembly");
}
try
{
return assembly.GetTypes();
}
catch (ReflectionTypeLoadException ex)
{
// If it fails we can still get a list of the Types it was able to resolve
return ex.Types.Where(t => t != null);
}
}
/// <summary>
/// Fires after MEF finishes finding composable parts within plugin assemblies
/// </summary>
@ -553,11 +606,6 @@ namespace MediaBrowser.Common.Kernel
{
return Task.Run(() =>
{
foreach (var task in ScheduledTasks)
{
task.Initialize(this, Logger);
}
// Start-up each plugin
Parallel.ForEach(Plugins, plugin =>
{
@ -608,22 +656,11 @@ namespace MediaBrowser.Common.Kernel
{
DisposeTcpManager();
DisposeTaskManager();
DisposeIsoManager();
DisposeHttpManager();
DisposeComposableParts();
}
}
/// <summary>
/// Disposes the iso manager.
/// </summary>
private void DisposeIsoManager()
{
if (IsoManager != null)
{
IsoManager.Dispose();
IsoManager = null;
_disposableParts.Clear();
}
}
@ -668,9 +705,9 @@ namespace MediaBrowser.Common.Kernel
/// </summary>
protected virtual void DisposeComposableParts()
{
if (CompositionContainer != null)
foreach (var part in _disposableParts)
{
CompositionContainer.Dispose();
part.Dispose();
}
}

View File

@ -43,5 +43,33 @@ namespace MediaBrowser.Common.Kernel
/// </summary>
/// <returns>Task.</returns>
Task UpdateApplication(CancellationToken cancellationToken, IProgress<double> progress);
/// <summary>
/// Creates an instance of type and resolves all constructor dependancies
/// </summary>
/// <param name="type">The type.</param>
/// <returns>System.Object.</returns>
object CreateInstance(Type type);
/// <summary>
/// Registers a service that other classes can use as a dependancy.
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="obj">The obj.</param>
void Register<T>(T obj) where T : class;
/// <summary>
/// Resolves this instance.
/// </summary>
/// <typeparam name="T"></typeparam>
/// <returns>``0.</returns>
T Resolve<T>();
/// <summary>
/// Resolves this instance.
/// </summary>
/// <typeparam name="T"></typeparam>
/// <returns>``0.</returns>
T TryResolve<T>();
}
}

View File

@ -1,12 +1,10 @@
using MediaBrowser.Common.Net;
using MediaBrowser.Common.Plugins;
using MediaBrowser.Common.ScheduledTasks;
using MediaBrowser.Common.Serialization;
using MediaBrowser.Model.Configuration;
using MediaBrowser.Model.System;
using System;
using System.Collections.Generic;
using System.Reflection;
using System.Threading.Tasks;
namespace MediaBrowser.Common.Kernel
@ -69,12 +67,6 @@ namespace MediaBrowser.Common.Kernel
/// <returns>SystemInfo.</returns>
SystemInfo GetSystemInfo();
/// <summary>
/// Gets the scheduled tasks.
/// </summary>
/// <value>The scheduled tasks.</value>
IEnumerable<IScheduledTask> ScheduledTasks { get; }
/// <summary>
/// Reloads the logger.
/// </summary>
@ -133,12 +125,6 @@ namespace MediaBrowser.Common.Kernel
/// <value>The TCP manager.</value>
TcpManager TcpManager { get; }
/// <summary>
/// Gets the task manager.
/// </summary>
/// <value>The task manager.</value>
TaskManager TaskManager { get; }
/// <summary>
/// Gets the web socket listeners.
/// </summary>
@ -160,12 +146,6 @@ namespace MediaBrowser.Common.Kernel
/// </summary>
event EventHandler<EventArgs> ConfigurationUpdated;
/// <summary>
/// Gets the assemblies.
/// </summary>
/// <value>The assemblies.</value>
Assembly[] Assemblies { get; }
/// <summary>
/// Gets the rest services.
/// </summary>

View File

@ -41,9 +41,6 @@
<Reference Include="Alchemy">
<HintPath>..\packages\Alchemy.2.2.1\lib\net40\Alchemy.dll</HintPath>
</Reference>
<Reference Include="MoreLinq">
<HintPath>..\packages\morelinq.1.0.15631-beta\lib\net35\MoreLinq.dll</HintPath>
</Reference>
<Reference Include="NLog">
<HintPath>..\packages\NLog.2.0.0.2000\lib\net40\NLog.dll</HintPath>
</Reference>
@ -92,7 +89,6 @@
<HintPath>..\packages\ServiceStack.Text.3.9.37\lib\net35\ServiceStack.Text.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.ComponentModel.Composition" />
<Reference Include="System.Configuration" />
<Reference Include="System.Core" />
<Reference Include="System.Management" />
@ -128,7 +124,6 @@
<Compile Include="Events\GenericEventArgs.cs" />
<Compile Include="Extensions\NamedLock.cs" />
<Compile Include="Extensions\ResourceNotFoundException.cs" />
<Compile Include="IO\FileSystem.cs" />
<Compile Include="IO\FileSystemRepository.cs" />
<Compile Include="IO\IIsoManager.cs" />
<Compile Include="IO\IIsoMount.cs" />
@ -141,8 +136,6 @@
<Compile Include="Kernel\IApplicationHost.cs" />
<Compile Include="Kernel\IKernel.cs" />
<Compile Include="Kernel\TcpManager.cs" />
<Compile Include="Localization\LocalizedStringData.cs" />
<Compile Include="Mef\MefUtils.cs" />
<Compile Include="Net\AlchemyWebSocket.cs" />
<Compile Include="Net\BaseRestService.cs" />
<Compile Include="Net\Handlers\BaseActionHandler.cs" />
@ -150,6 +143,7 @@
<Compile Include="Net\Handlers\StaticFileHandler.cs" />
<Compile Include="Net\HttpManager.cs" />
<Compile Include="Net\IRestfulService.cs" />
<Compile Include="Net\IUdpServer.cs" />
<Compile Include="Net\IWebSocket.cs" />
<Compile Include="Net\MimeTypes.cs" />
<Compile Include="Net\NativeWebSocket.cs" />
@ -165,6 +159,7 @@
<DesignTime>True</DesignTime>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
<Compile Include="ScheduledTasks\ITaskManager.cs" />
<Compile Include="ScheduledTasks\TaskManager.cs" />
<Compile Include="ScheduledTasks\Tasks\ReloadLoggerTask.cs" />
<Compile Include="ScheduledTasks\ScheduledTaskHelpers.cs" />
@ -229,6 +224,9 @@
<ItemGroup />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="$(SolutionDir)\.nuget\nuget.targets" />
<PropertyGroup>
<PostBuildEvent>xcopy "$(TargetPath)" "$(SolutionDir)\Nuget\dlls\" /y /d /r /i</PostBuildEvent>
</PropertyGroup>
<!-- 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">

View File

@ -1,80 +0,0 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.Composition.Hosting;
using System.ComponentModel.Composition.Primitives;
using System.Linq;
using System.Reflection;
namespace MediaBrowser.Common.Mef
{
/// <summary>
/// Class MefUtils
/// </summary>
public static class MefUtils
{
/// <summary>
/// Plugins that live on both the server and UI are going to have references to assemblies from both sides.
/// But looks for Parts on one side, it will throw an exception when it seems Types from the other side that it doesn't have a reference to.
/// For example, a plugin provides a Resolver. When MEF runs in the UI, it will throw an exception when it sees the resolver because there won't be a reference to the base class.
/// This method will catch those exceptions while retining the list of Types that MEF is able to resolve.
/// </summary>
/// <param name="catalogs">The catalogs.</param>
/// <returns>CompositionContainer.</returns>
/// <exception cref="System.ArgumentNullException">catalogs</exception>
public static CompositionContainer GetSafeCompositionContainer(IEnumerable<ComposablePartCatalog> catalogs)
{
if (catalogs == null)
{
throw new ArgumentNullException("catalogs");
}
var newList = new List<ComposablePartCatalog>();
// Go through each Catalog
foreach (var catalog in catalogs)
{
try
{
// Try to have MEF find Parts
catalog.Parts.ToArray();
// If it succeeds we can use the entire catalog
newList.Add(catalog);
}
catch (ReflectionTypeLoadException ex)
{
// If it fails we can still get a list of the Types it was able to resolve and create TypeCatalogs
var typeCatalogs = ex.Types.Where(t => t != null).Select(t => new TypeCatalog(t));
newList.AddRange(typeCatalogs);
}
}
return new CompositionContainer(new AggregateCatalog(newList));
}
/// <summary>
/// Gets a list of types within an assembly
/// This will handle situations that would normally throw an exception - such as a type within the assembly that depends on some other non-existant reference
/// </summary>
/// <param name="assembly">The assembly.</param>
/// <returns>IEnumerable{Type}.</returns>
/// <exception cref="System.ArgumentNullException">assembly</exception>
public static IEnumerable<Type> GetTypes(Assembly assembly)
{
if (assembly == null)
{
throw new ArgumentNullException("assembly");
}
try
{
return assembly.GetTypes();
}
catch (ReflectionTypeLoadException ex)
{
// If it fails we can still get a list of the Types it was able to resolve
return ex.Types.Where(t => t != null);
}
}
}
}

View File

@ -4,6 +4,7 @@ using MediaBrowser.Common.Kernel;
using MediaBrowser.Model.Logging;
using ServiceStack.Api.Swagger;
using ServiceStack.Common.Web;
using ServiceStack.Configuration;
using ServiceStack.Logging.NLogger;
using ServiceStack.ServiceHost;
using ServiceStack.ServiceInterface.Cors;
@ -153,6 +154,8 @@ namespace MediaBrowser.Common.Net
DebugMode = true
});
}
container.Adapter = new ContainerAdapter(ApplicationHost);
container.Register(Kernel);
container.Register(_logger);
@ -464,4 +467,23 @@ namespace MediaBrowser.Common.Net
/// <value>The endpoint.</value>
public IPEndPoint Endpoint { get; set; }
}
class ContainerAdapter : IContainerAdapter
{
private readonly IApplicationHost _appHost;
public ContainerAdapter(IApplicationHost appHost)
{
_appHost = appHost;
}
public T Resolve<T>()
{
return _appHost.Resolve<T>();
}
public T TryResolve<T>()
{
return _appHost.TryResolve<T>();
}
}
}

View File

@ -0,0 +1,7 @@

namespace MediaBrowser.Common.Net
{
public interface IUdpServer
{
}
}

View File

@ -17,7 +17,7 @@ namespace MediaBrowser.Common.ScheduledTasks
/// </summary>
/// <typeparam name="TKernelType">The type of the T kernel type.</typeparam>
public abstract class BaseScheduledTask<TKernelType> : IScheduledTask
where TKernelType : IKernel
where TKernelType : class, IKernel
{
/// <summary>
/// Gets the kernel.
@ -25,6 +25,47 @@ namespace MediaBrowser.Common.ScheduledTasks
/// <value>The kernel.</value>
protected TKernelType Kernel { get; private set; }
/// <summary>
/// Gets the logger.
/// </summary>
/// <value>The logger.</value>
protected ILogger Logger { get; private set; }
/// <summary>
/// Gets the task manager.
/// </summary>
/// <value>The task manager.</value>
protected ITaskManager TaskManager { get; private set; }
/// <summary>
/// Initializes a new instance of the <see cref="BaseScheduledTask{TKernelType}" /> class.
/// </summary>
/// <param name="kernel">The kernel.</param>
/// <param name="taskManager">The task manager.</param>
/// <param name="logger">The logger.</param>
/// <exception cref="System.ArgumentNullException">kernel</exception>
protected BaseScheduledTask(TKernelType kernel, ITaskManager taskManager, ILogger logger)
{
if (kernel == null)
{
throw new ArgumentNullException("kernel");
}
if (taskManager == null)
{
throw new ArgumentNullException("taskManager");
}
if (logger == null)
{
throw new ArgumentNullException("logger");
}
Kernel = kernel;
TaskManager = taskManager;
Logger = logger;
ReloadTriggerEvents(true);
}
/// <summary>
/// The _last execution result
/// </summary>
@ -199,7 +240,7 @@ namespace MediaBrowser.Common.ScheduledTasks
try
{
return JsonSerializer.DeserializeFromFile<IEnumerable<TaskTriggerInfo>>(ConfigurationFilePath)
.Select(t => ScheduledTaskHelpers.GetTrigger(t, Kernel))
.Select(ScheduledTaskHelpers.GetTrigger)
.ToList();
}
catch (IOException)
@ -228,7 +269,7 @@ namespace MediaBrowser.Common.ScheduledTasks
_triggersInitialized = true;
ReloadTriggerEvents();
ReloadTriggerEvents(false);
JsonSerializer.SerializeToFile(_triggers.Select(ScheduledTaskHelpers.GetTriggerInfo), ConfigurationFilePath);
}
@ -290,29 +331,11 @@ namespace MediaBrowser.Common.ScheduledTasks
}
}
/// <summary>
/// Gets the logger.
/// </summary>
/// <value>The logger.</value>
protected ILogger Logger { get; private set; }
/// <summary>
/// Initializes the specified kernel.
/// </summary>
/// <param name="kernel">The kernel.</param>
/// <param name="logger">The logger.</param>
public void Initialize(IKernel kernel, ILogger logger)
{
Logger = logger;
Kernel = (TKernelType)kernel;
ReloadTriggerEvents();
}
/// <summary>
/// Reloads the trigger events.
/// </summary>
private void ReloadTriggerEvents()
/// <param name="isApplicationStartup">if set to <c>true</c> [is application startup].</param>
private void ReloadTriggerEvents(bool isApplicationStartup)
{
foreach (var trigger in Triggers)
{
@ -320,7 +343,7 @@ namespace MediaBrowser.Common.ScheduledTasks
trigger.Triggered -= trigger_Triggered;
trigger.Triggered += trigger_Triggered;
trigger.Start();
trigger.Start(isApplicationStartup);
}
}
@ -335,7 +358,7 @@ namespace MediaBrowser.Common.ScheduledTasks
Logger.Info("{0} fired for task: {1}", trigger.GetType().Name, Name);
Kernel.TaskManager.QueueScheduledTask(this);
TaskManager.QueueScheduledTask(this);
}
/// <summary>
@ -392,7 +415,7 @@ namespace MediaBrowser.Common.ScheduledTasks
CurrentCancellationTokenSource = null;
CurrentProgress = null;
Kernel.TaskManager.OnTaskCompleted(this);
TaskManager.OnTaskCompleted(this);
}
/// <summary>

View File

@ -27,13 +27,13 @@ namespace MediaBrowser.Common.ScheduledTasks
await Task.Delay(1000).ConfigureAwait(false);
Start();
Start(false);
}
/// <summary>
/// Stars waiting for the trigger action
/// </summary>
protected internal abstract void Start();
protected internal abstract void Start(bool isApplicationStartup);
/// <summary>
/// Stops waiting for the trigger action

View File

@ -23,7 +23,8 @@ namespace MediaBrowser.Common.ScheduledTasks
/// <summary>
/// Stars waiting for the trigger action
/// </summary>
protected internal override void Start()
/// <param name="isApplicationStartup">if set to <c>true</c> [is application startup].</param>
protected internal override void Start(bool isApplicationStartup)
{
DisposeTimer();

View File

@ -1,6 +1,4 @@
using MediaBrowser.Common.Kernel;
using MediaBrowser.Model.Logging;
using MediaBrowser.Model.Tasks;
using MediaBrowser.Model.Tasks;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
@ -73,13 +71,6 @@ namespace MediaBrowser.Common.ScheduledTasks
/// <exception cref="System.InvalidOperationException">Cannot cancel a Task unless it is in the Running state.</exception>
void Cancel();
/// <summary>
/// Initializes the specified kernel.
/// </summary>
/// <param name="kernel">The kernel.</param>
/// <param name="logger">The logger.</param>
void Initialize(IKernel kernel, ILogger logger);
/// <summary>
/// Cancels if running.
/// </summary>

View File

@ -0,0 +1,46 @@
using System;
using System.Collections.Generic;
namespace MediaBrowser.Common.ScheduledTasks
{
public interface ITaskManager : IDisposable
{
/// <summary>
/// Gets the list of Scheduled Tasks
/// </summary>
/// <value>The scheduled tasks.</value>
IScheduledTask[] ScheduledTasks { get; }
/// <summary>
/// Cancels if running and queue.
/// </summary>
/// <typeparam name="T"></typeparam>
void CancelIfRunningAndQueue<T>()
where T : IScheduledTask;
/// <summary>
/// Queues the scheduled task.
/// </summary>
/// <typeparam name="T"></typeparam>
void QueueScheduledTask<T>()
where T : IScheduledTask;
/// <summary>
/// Queues the scheduled task.
/// </summary>
/// <param name="task">The task.</param>
void QueueScheduledTask(IScheduledTask task);
/// <summary>
/// Adds the tasks.
/// </summary>
/// <param name="tasks">The tasks.</param>
void AddTasks(IEnumerable<IScheduledTask> tasks);
/// <summary>
/// Called when [task completed].
/// </summary>
/// <param name="task">The task.</param>
void OnTaskCompleted(IScheduledTask task);
}
}

View File

@ -23,7 +23,8 @@ namespace MediaBrowser.Common.ScheduledTasks
/// <summary>
/// Stars waiting for the trigger action
/// </summary>
protected internal override void Start()
/// <param name="isApplicationStartup">if set to <c>true</c> [is application startup].</param>
protected internal override void Start(bool isApplicationStartup)
{
DisposeTimer();

View File

@ -78,11 +78,10 @@ namespace MediaBrowser.Common.ScheduledTasks
/// Converts a TaskTriggerInfo into a concrete BaseTaskTrigger
/// </summary>
/// <param name="info">The info.</param>
/// <param name="kernel">The kernel.</param>
/// <returns>BaseTaskTrigger.</returns>
/// <exception cref="System.ArgumentNullException"></exception>
/// <exception cref="System.ArgumentException">Invalid trigger type: + info.Type</exception>
public static BaseTaskTrigger GetTrigger(TaskTriggerInfo info, IKernel kernel)
public static BaseTaskTrigger GetTrigger(TaskTriggerInfo info)
{
if (info.Type.Equals(typeof(DailyTrigger).Name, StringComparison.OrdinalIgnoreCase))
{
@ -144,7 +143,7 @@ namespace MediaBrowser.Common.ScheduledTasks
if (info.Type.Equals(typeof(StartupTrigger).Name, StringComparison.OrdinalIgnoreCase))
{
return new StartupTrigger(kernel);
return new StartupTrigger();
}
throw new ArgumentException("Unrecognized trigger type: " + info.Type);

View File

@ -1,6 +1,4 @@
using MediaBrowser.Common.Kernel;
using System;
using System.Threading.Tasks;
using System.Threading.Tasks;
namespace MediaBrowser.Common.ScheduledTasks
{
@ -9,34 +7,18 @@ namespace MediaBrowser.Common.ScheduledTasks
/// </summary>
public class StartupTrigger : BaseTaskTrigger
{
/// <summary>
/// Gets the kernel.
/// </summary>
/// <value>The kernel.</value>
protected IKernel Kernel { get; private set; }
/// <summary>
/// Initializes a new instance of the <see cref="StartupTrigger" /> class.
/// </summary>
/// <param name="kernel">The kernel.</param>
public StartupTrigger(IKernel kernel)
{
Kernel = kernel;
}
/// <summary>
/// Stars waiting for the trigger action
/// </summary>
protected internal override void Start()
/// <param name="isApplicationStartup">if set to <c>true</c> [is application startup].</param>
protected internal async override void Start(bool isApplicationStartup)
{
Kernel.ReloadCompleted += Kernel_ReloadCompleted;
}
if (isApplicationStartup)
{
await Task.Delay(2000).ConfigureAwait(false);
async void Kernel_ReloadCompleted(object sender, EventArgs e)
{
await Task.Delay(2000).ConfigureAwait(false);
OnTriggered();
OnTriggered();
}
}
/// <summary>
@ -44,7 +26,6 @@ namespace MediaBrowser.Common.ScheduledTasks
/// </summary>
protected internal override void Stop()
{
Kernel.ReloadCompleted -= Kernel_ReloadCompleted;
}
}
}

View File

@ -18,7 +18,8 @@ namespace MediaBrowser.Common.ScheduledTasks
/// <summary>
/// Stars waiting for the trigger action
/// </summary>
protected internal override void Start()
/// <param name="isApplicationStartup">if set to <c>true</c> [is application startup].</param>
protected internal override void Start(bool isApplicationStartup)
{
switch (SystemEvent)
{

View File

@ -1,5 +1,4 @@
using MediaBrowser.Common.Kernel;
using MediaBrowser.Model.Logging;
using MediaBrowser.Model.Logging;
using MediaBrowser.Model.Tasks;
using System;
using System.Collections.Generic;
@ -10,8 +9,14 @@ namespace MediaBrowser.Common.ScheduledTasks
/// <summary>
/// Class TaskManager
/// </summary>
public class TaskManager : BaseManager<IKernel>
internal class TaskManager : ITaskManager
{
/// <summary>
/// Gets the list of Scheduled Tasks
/// </summary>
/// <value>The scheduled tasks.</value>
public IScheduledTask[] ScheduledTasks { get; private set; }
/// <summary>
/// The _task queue
/// </summary>
@ -25,12 +30,17 @@ namespace MediaBrowser.Common.ScheduledTasks
/// <summary>
/// Initializes a new instance of the <see cref="TaskManager" /> class.
/// </summary>
/// <param name="kernel">The kernel.</param>
/// <param name="logger">The logger.</param>
public TaskManager(IKernel kernel, ILogger logger)
: base(kernel)
public TaskManager(ILogger logger)
{
if (logger == null)
{
throw new ArgumentException("logger");
}
_logger = logger;
ScheduledTasks = new IScheduledTask[] {};
}
/// <summary>
@ -40,7 +50,7 @@ namespace MediaBrowser.Common.ScheduledTasks
public void CancelIfRunningAndQueue<T>()
where T : IScheduledTask
{
Kernel.ScheduledTasks.OfType<T>().First().CancelIfRunning();
ScheduledTasks.OfType<T>().First().CancelIfRunning();
QueueScheduledTask<T>();
}
@ -51,7 +61,7 @@ namespace MediaBrowser.Common.ScheduledTasks
public void QueueScheduledTask<T>()
where T : IScheduledTask
{
var scheduledTask = Kernel.ScheduledTasks.OfType<T>().First();
var scheduledTask = ScheduledTasks.OfType<T>().First();
QueueScheduledTask(scheduledTask);
}
@ -64,7 +74,7 @@ namespace MediaBrowser.Common.ScheduledTasks
{
var type = task.GetType();
var scheduledTask = Kernel.ScheduledTasks.First(t => t.GetType() == type);
var scheduledTask = ScheduledTasks.First(t => t.GetType() == type);
lock (_taskQueue)
{
@ -91,7 +101,7 @@ namespace MediaBrowser.Common.ScheduledTasks
/// Called when [task completed].
/// </summary>
/// <param name="task">The task.</param>
internal void OnTaskCompleted(IScheduledTask task)
public void OnTaskCompleted(IScheduledTask task)
{
// Execute queued tasks
lock (_taskQueue)
@ -100,7 +110,7 @@ namespace MediaBrowser.Common.ScheduledTasks
foreach (var type in copy)
{
var scheduledTask = Kernel.ScheduledTasks.First(t => t.GetType() == type);
var scheduledTask = ScheduledTasks.First(t => t.GetType() == type);
if (scheduledTask.State == TaskState.Idle)
{
@ -111,5 +121,39 @@ namespace MediaBrowser.Common.ScheduledTasks
}
}
}
/// <summary>
/// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
/// </summary>
public void Dispose()
{
Dispose(true);
GC.SuppressFinalize(this);
}
/// <summary>
/// Releases unmanaged and - optionally - managed resources.
/// </summary>
/// <param name="dispose"><c>true</c> to release both managed and unmanaged resources; <c>false</c> to release only unmanaged resources.</param>
protected virtual void Dispose(bool dispose)
{
foreach (var task in ScheduledTasks)
{
task.Dispose();
}
}
/// <summary>
/// Adds the tasks.
/// </summary>
/// <param name="tasks">The tasks.</param>
public void AddTasks(IEnumerable<IScheduledTask> tasks)
{
var myTasks = ScheduledTasks.ToList();
myTasks.AddRange(tasks);
ScheduledTasks = myTasks.ToArray();
}
}
}

View File

@ -1,8 +1,7 @@
using MediaBrowser.Common.Kernel;
using MediaBrowser.Model.Tasks;
using MediaBrowser.Model.Logging;
using System;
using System.Collections.Generic;
using System.ComponentModel.Composition;
using System.IO;
using System.Linq;
using System.Threading;
@ -13,9 +12,19 @@ namespace MediaBrowser.Common.ScheduledTasks.Tasks
/// <summary>
/// Deletes old cache files
/// </summary>
[Export(typeof(IScheduledTask))]
public class DeleteCacheFileTask : BaseScheduledTask<IKernel>
{
/// <summary>
/// Initializes a new instance of the <see cref="DeleteCacheFileTask" /> class.
/// </summary>
/// <param name="kernel">The kernel.</param>
/// <param name="taskManager">The task manager.</param>
/// <param name="logger">The logger.</param>
public DeleteCacheFileTask(IKernel kernel, ITaskManager taskManager, ILogger logger)
: base(kernel, taskManager, logger)
{
}
/// <summary>
/// Creates the triggers that define when the task will run
/// </summary>

View File

@ -1,8 +1,7 @@
using MediaBrowser.Common.Kernel;
using MediaBrowser.Model.Tasks;
using MediaBrowser.Model.Logging;
using System;
using System.Collections.Generic;
using System.ComponentModel.Composition;
using System.IO;
using System.Linq;
using System.Threading;
@ -13,9 +12,19 @@ namespace MediaBrowser.Common.ScheduledTasks.Tasks
/// <summary>
/// Deletes old log files
/// </summary>
[Export(typeof(IScheduledTask))]
public class DeleteLogFileTask : BaseScheduledTask<IKernel>
{
/// <summary>
/// Initializes a new instance of the <see cref="DeleteLogFileTask" /> class.
/// </summary>
/// <param name="kernel">The kernel.</param>
/// <param name="taskManager">The task manager.</param>
/// <param name="logger">The logger.</param>
public DeleteLogFileTask(IKernel kernel, ITaskManager taskManager, ILogger logger)
: base(kernel, taskManager, logger)
{
}
/// <summary>
/// Creates the triggers that define when the task will run
/// </summary>

View File

@ -1,8 +1,7 @@
using MediaBrowser.Common.Kernel;
using MediaBrowser.Model.Tasks;
using MediaBrowser.Model.Logging;
using System;
using System.Collections.Generic;
using System.ComponentModel.Composition;
using System.Threading;
using System.Threading.Tasks;
@ -11,9 +10,19 @@ namespace MediaBrowser.Common.ScheduledTasks.Tasks
/// <summary>
/// Class ReloadLoggerFileTask
/// </summary>
[Export(typeof(IScheduledTask))]
public class ReloadLoggerFileTask : BaseScheduledTask<IKernel>
{
/// <summary>
/// Initializes a new instance of the <see cref="ReloadLoggerFileTask" /> class.
/// </summary>
/// <param name="kernel">The kernel.</param>
/// <param name="taskManager">The task manager.</param>
/// <param name="logger">The logger.</param>
public ReloadLoggerFileTask(IKernel kernel, ITaskManager taskManager, ILogger logger)
: base(kernel, taskManager, logger)
{
}
/// <summary>
/// Gets the default triggers.
/// </summary>

View File

@ -1,7 +1,7 @@
using MediaBrowser.Common.Kernel;
using MediaBrowser.Model.Logging;
using System;
using System.Collections.Generic;
using System.ComponentModel.Composition;
using System.Threading;
using System.Threading.Tasks;
@ -10,7 +10,6 @@ namespace MediaBrowser.Common.ScheduledTasks.Tasks
/// <summary>
/// Plugin Update Task
/// </summary>
[Export(typeof(IScheduledTask))]
public class SystemUpdateTask : BaseScheduledTask<IKernel>
{
/// <summary>
@ -22,8 +21,11 @@ namespace MediaBrowser.Common.ScheduledTasks.Tasks
/// Initializes a new instance of the <see cref="SystemUpdateTask" /> class.
/// </summary>
/// <param name="appHost">The app host.</param>
[ImportingConstructor]
public SystemUpdateTask([Import("appHost")] IApplicationHost appHost)
/// <param name="taskManager">The task manager.</param>
/// <param name="kernel">The kernel.</param>
/// <param name="logger">The logger.</param>
public SystemUpdateTask(IApplicationHost appHost, ITaskManager taskManager, IKernel kernel, ILogger logger)
: base(kernel, taskManager, logger)
{
_appHost = appHost;
}

View File

@ -29,7 +29,8 @@ namespace MediaBrowser.Common.ScheduledTasks
/// <summary>
/// Stars waiting for the trigger action
/// </summary>
protected internal override void Start()
/// <param name="isApplicationStartup">if set to <c>true</c> [is application startup].</param>
protected internal override void Start(bool isApplicationStartup)
{
DisposeTimer();

View File

@ -1,11 +1,9 @@
using MediaBrowser.Common.Mef;
using ProtoBuf;
using ProtoBuf;
using ProtoBuf.Meta;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
namespace MediaBrowser.Common.Serialization
{
@ -135,21 +133,20 @@ namespace MediaBrowser.Common.Serialization
/// <summary>
/// Creates the specified assemblies.
/// </summary>
/// <param name="assemblies">The assemblies.</param>
/// <returns>DynamicProtobufSerializer.</returns>
/// <exception cref="System.ArgumentNullException">assemblies</exception>
public static DynamicProtobufSerializer Create(IEnumerable<Assembly> assemblies)
public static DynamicProtobufSerializer Create(IEnumerable<Type> types)
{
if (assemblies == null)
if (types == null)
{
throw new ArgumentNullException("assemblies");
throw new ArgumentNullException("types");
}
var model = TypeModel.Create();
var attributeType = typeof(ProtoContractAttribute);
// Find all ProtoContracts in the current assembly
foreach (var type in assemblies.SelectMany(a => MefUtils.GetTypes(a).Where(t => Attribute.IsDefined(t, attributeType))))
foreach (var type in types.Where(t => Attribute.IsDefined(t, attributeType)))
{
model.Add(type, true);
}

View File

@ -1,7 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Alchemy" version="2.2.1" targetFramework="net45" />
<package id="morelinq" version="1.0.15631-beta" targetFramework="net45" />
<package id="NLog" version="2.0.0.2000" targetFramework="net45" />
<package id="protobuf-net" version="2.0.0.621" targetFramework="net45" />
<package id="Rx-Core" version="2.0.21114" targetFramework="net45" />

View File

@ -541,7 +541,7 @@ namespace MediaBrowser.Controller.Drawing
/// <param name="imageType">Type of the image.</param>
/// <returns>Guid.</returns>
/// <exception cref="System.ArgumentNullException">item</exception>
public Guid GetImageCacheTag(string originalImagePath, DateTime dateModified, IEnumerable<BaseImageEnhancer> imageEnhancers, BaseItem item, ImageType imageType)
public Guid GetImageCacheTag(string originalImagePath, DateTime dateModified, IEnumerable<IImageEnhancer> imageEnhancers, BaseItem item, ImageType imageType)
{
if (item == null)
{
@ -574,7 +574,7 @@ namespace MediaBrowser.Controller.Drawing
/// <param name="imageType">Type of the image.</param>
/// <param name="imageIndex">Index of the image.</param>
/// <returns>Task{EnhancedImage}.</returns>
private async Task<Image> ExecuteImageEnhancers(IEnumerable<BaseImageEnhancer> imageEnhancers, Image originalImage, BaseItem item, ImageType imageType, int imageIndex)
private async Task<Image> ExecuteImageEnhancers(IEnumerable<IImageEnhancer> imageEnhancers, Image originalImage, BaseItem item, ImageType imageType, int imageIndex)
{
var result = originalImage;

View File

@ -0,0 +1,15 @@

namespace MediaBrowser.Controller.Entities
{
/// <summary>
/// Interface IVirtualFolderCreator
/// </summary>
public interface IVirtualFolderCreator
{
/// <summary>
/// Gets the folder.
/// </summary>
/// <returns>Folder.</returns>
BasePluginFolder GetFolder();
}
}

View File

@ -1,6 +1,7 @@
using MediaBrowser.Common.Extensions;
using MediaBrowser.Common.IO;
using MediaBrowser.Common.Win32;
using MediaBrowser.Controller.IO;
using MediaBrowser.Model.Entities;
using System;
using System.Collections.Generic;

View File

@ -2,6 +2,7 @@
using MediaBrowser.Common.Extensions;
using MediaBrowser.Common.IO;
using MediaBrowser.Common.Win32;
using MediaBrowser.Controller.IO;
using MediaBrowser.Controller.Library;
using MediaBrowser.Controller.Localization;
using MediaBrowser.Model.Entities;

View File

@ -1,6 +1,7 @@
using MediaBrowser.Common.Extensions;
using MediaBrowser.Common.IO;
using MediaBrowser.Common.Serialization;
using MediaBrowser.Controller.IO;
using MediaBrowser.Model.Configuration;
using MediaBrowser.Model.Tasks;
using System;

View File

@ -1,4 +1,5 @@
using MediaBrowser.Common.IO;
using MediaBrowser.Common.ScheduledTasks;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Library;
using MediaBrowser.Controller.ScheduledTasks;
@ -66,16 +67,27 @@ namespace MediaBrowser.Controller.IO
/// <value>The logger.</value>
private ILogger Logger { get; set; }
/// <summary>
/// Gets or sets the task manager.
/// </summary>
/// <value>The task manager.</value>
private ITaskManager TaskManager { get; set; }
/// <summary>
/// Initializes a new instance of the <see cref="DirectoryWatchers" /> class.
/// </summary>
public DirectoryWatchers(ILogger logger)
public DirectoryWatchers(ILogger logger, ITaskManager taskManager)
{
if (logger == null)
{
throw new ArgumentNullException("logger");
}
if (taskManager == null)
{
throw new ArgumentNullException("taskManager");
}
TaskManager = taskManager;
Logger = logger;
}
@ -421,7 +433,7 @@ namespace MediaBrowser.Controller.IO
// If the root folder changed, run the library task so the user can see it
if (itemsToRefresh.Any(i => i is AggregateFolder))
{
Kernel.Instance.TaskManager.CancelIfRunningAndQueue<RefreshMediaLibraryTask>();
TaskManager.CancelIfRunningAndQueue<RefreshMediaLibraryTask>();
return;
}

View File

@ -6,7 +6,7 @@ using System.IO;
using System.Runtime.InteropServices;
using System.Text;
namespace MediaBrowser.Common.IO
namespace MediaBrowser.Controller.IO
{
/// <summary>
/// Class FileSystem

View File

@ -1,5 +1,6 @@
using MediaBrowser.Common.IO;
using MediaBrowser.Common.Kernel;
using MediaBrowser.Common.ScheduledTasks;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Model.Logging;
using System;
@ -26,17 +27,18 @@ namespace MediaBrowser.Controller.IO
/// The _logger
/// </summary>
private readonly ILogger _logger;
/// <summary>
/// Initializes a new instance of the <see cref="FileSystemManager" /> class.
/// </summary>
/// <param name="kernel">The kernel.</param>
/// <param name="logger">The logger.</param>
public FileSystemManager(Kernel kernel, ILogger logger)
/// <param name="taskManager">The task manager.</param>
public FileSystemManager(Kernel kernel, ILogger logger, ITaskManager taskManager)
: base(kernel)
{
_logger = logger;
DirectoryWatchers = new DirectoryWatchers(logger);
DirectoryWatchers = new DirectoryWatchers(logger, taskManager);
}
/// <summary>

View File

@ -1,5 +1,4 @@
using MediaBrowser.Common.IO;
using MediaBrowser.Common.Kernel;
using MediaBrowser.Common.Kernel;
using MediaBrowser.Common.Plugins;
using MediaBrowser.Controller.Drawing;
using MediaBrowser.Controller.Entities;
@ -16,14 +15,10 @@ using MediaBrowser.Controller.ScheduledTasks;
using MediaBrowser.Controller.Updates;
using MediaBrowser.Controller.Weather;
using MediaBrowser.Model.Configuration;
using MediaBrowser.Model.IO;
using MediaBrowser.Model.Logging;
using MediaBrowser.Model.MediaInfo;
using MediaBrowser.Model.System;
using System;
using System.Collections.Generic;
using System.ComponentModel.Composition;
using System.ComponentModel.Composition.Hosting;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
@ -178,32 +173,34 @@ namespace MediaBrowser.Controller
get { return KernelContext.Server; }
}
/// <summary>
/// Gets the list of Localized string files
/// </summary>
/// <value>The string files.</value>
public IEnumerable<LocalizedStringData> StringFiles { get; private set; }
/// <summary>
/// Gets the list of plugin configuration pages
/// </summary>
/// <value>The configuration pages.</value>
[ImportMany(typeof(IPluginConfigurationPage))]
public IEnumerable<IPluginConfigurationPage> PluginConfigurationPages { get; private set; }
/// <summary>
/// Gets the intro providers.
/// </summary>
/// <value>The intro providers.</value>
[ImportMany(typeof(IIntroProvider))]
public IEnumerable<IIntroProvider> IntroProviders { get; private set; }
/// <summary>
/// Gets the list of currently registered weather prvoiders
/// </summary>
/// <value>The weather providers.</value>
[ImportMany(typeof(IWeatherProvider))]
public IEnumerable<IWeatherProvider> WeatherProviders { get; private set; }
/// <summary>
/// Gets the list of currently registered metadata prvoiders
/// </summary>
/// <value>The metadata providers enumerable.</value>
[ImportMany(typeof(BaseMetadataProvider))]
public BaseMetadataProvider[] MetadataProviders { get; private set; }
/// <summary>
@ -211,28 +208,24 @@ namespace MediaBrowser.Controller
/// Image processors are specialized metadata providers that run after the normal ones
/// </summary>
/// <value>The image enhancers.</value>
[ImportMany(typeof(BaseImageEnhancer))]
public BaseImageEnhancer[] ImageEnhancers { get; private set; }
public IEnumerable<IImageEnhancer> ImageEnhancers { get; private set; }
/// <summary>
/// Gets the list of currently registered entity resolvers
/// </summary>
/// <value>The entity resolvers enumerable.</value>
[ImportMany(typeof(IBaseItemResolver))]
internal IBaseItemResolver[] EntityResolvers { get; private set; }
internal IEnumerable<IBaseItemResolver> EntityResolvers { get; private set; }
/// <summary>
/// Gets the list of BasePluginFolders added by plugins
/// </summary>
/// <value>The plugin folders.</value>
[ImportMany(typeof(BasePluginFolder))]
internal IEnumerable<BasePluginFolder> PluginFolders { get; private set; }
internal IEnumerable<IVirtualFolderCreator> PluginFolderCreators { get; private set; }
/// <summary>
/// Gets the list of available user repositories
/// </summary>
/// <value>The user repositories.</value>
[ImportMany(typeof(IUserRepository))]
private IEnumerable<IUserRepository> UserRepositories { get; set; }
/// <summary>
@ -251,7 +244,6 @@ namespace MediaBrowser.Controller
/// Gets the list of available item repositories
/// </summary>
/// <value>The item repositories.</value>
[ImportMany(typeof(IItemRepository))]
private IEnumerable<IItemRepository> ItemRepositories { get; set; }
/// <summary>
@ -264,22 +256,19 @@ namespace MediaBrowser.Controller
/// Gets the list of available item repositories
/// </summary>
/// <value>The user data repositories.</value>
[ImportMany(typeof(IUserDataRepository))]
private IEnumerable<IUserDataRepository> UserDataRepositories { get; set; }
/// <summary>
/// Gets the list of available DisplayPreferencesRepositories
/// </summary>
/// <value>The display preferences repositories.</value>
[ImportMany(typeof(IDisplayPreferencesRepository))]
private IEnumerable<IDisplayPreferencesRepository> DisplayPreferencesRepositories { get; set; }
/// <summary>
/// Gets the list of entity resolution ignore rules
/// </summary>
/// <value>The entity resolution ignore rules.</value>
[ImportMany(typeof(BaseResolutionIgnoreRule))]
internal IEnumerable<BaseResolutionIgnoreRule> EntityResolutionIgnoreRules { get; private set; }
internal IEnumerable<IResolutionIgnoreRule> EntityResolutionIgnoreRules { get; private set; }
/// <summary>
/// Gets the active user data repository
@ -302,48 +291,16 @@ namespace MediaBrowser.Controller
get { return 7359; }
}
/// <summary>
/// Gets or sets the zip client.
/// </summary>
/// <value>The zip client.</value>
private IZipClient ZipClient { get; set; }
/// <summary>
/// Gets or sets the bluray examiner.
/// </summary>
/// <value>The bluray examiner.</value>
private IBlurayExaminer BlurayExaminer { get; set; }
/// <summary>
/// Creates a kernel based on a Data path, which is akin to our current programdata path
/// </summary>
/// <param name="appHost">The app host.</param>
/// <param name="isoManager">The iso manager.</param>
/// <param name="zipClient">The zip client.</param>
/// <param name="blurayExaminer">The bluray examiner.</param>
/// <param name="logger">The logger.</param>
/// <exception cref="System.ArgumentNullException">isoManager</exception>
public Kernel(IApplicationHost appHost, IIsoManager isoManager, IZipClient zipClient, IBlurayExaminer blurayExaminer, ILogger logger)
: base(appHost, isoManager, logger)
public Kernel(IApplicationHost appHost, ILogger logger)
: base(appHost, logger)
{
if (isoManager == null)
{
throw new ArgumentNullException("isoManager");
}
if (zipClient == null)
{
throw new ArgumentNullException("zipClient");
}
if (blurayExaminer == null)
{
throw new ArgumentNullException("blurayExaminer");
}
Instance = this;
ZipClient = zipClient;
BlurayExaminer = blurayExaminer;
// For now there's no real way to inject this properly
BaseItem.Logger = logger;
@ -356,13 +313,43 @@ namespace MediaBrowser.Controller
/// <summary>
/// Composes the exported values.
/// </summary>
/// <param name="container">The container.</param>
protected override void ComposeExportedValues(CompositionContainer container)
protected override void RegisterExportedValues()
{
base.ComposeExportedValues(container);
ApplicationHost.Register(this);
base.RegisterExportedValues();
}
container.ComposeExportedValue("kernel", this);
container.ComposeExportedValue("blurayExaminer", BlurayExaminer);
/// <summary>
/// Composes the parts with ioc container.
/// </summary>
/// <param name="allTypes">All types.</param>
protected override void FindParts(Type[] allTypes)
{
InstallationManager = (InstallationManager)ApplicationHost.CreateInstance(typeof(InstallationManager));
FFMpegManager = (FFMpegManager)ApplicationHost.CreateInstance(typeof(FFMpegManager));
LibraryManager = (LibraryManager)ApplicationHost.CreateInstance(typeof(LibraryManager));
UserManager = (UserManager)ApplicationHost.CreateInstance(typeof(UserManager));
ImageManager = (ImageManager)ApplicationHost.CreateInstance(typeof(ImageManager));
ProviderManager = (ProviderManager)ApplicationHost.CreateInstance(typeof(ProviderManager));
UserDataManager = (UserDataManager)ApplicationHost.CreateInstance(typeof(UserDataManager));
PluginSecurityManager = (PluginSecurityManager)ApplicationHost.CreateInstance(typeof(PluginSecurityManager));
base.FindParts(allTypes);
EntityResolutionIgnoreRules = GetExports<IResolutionIgnoreRule>(allTypes);
UserDataRepositories = GetExports<IUserDataRepository>(allTypes);
UserRepositories = GetExports<IUserRepository>(allTypes);
DisplayPreferencesRepositories = GetExports<IDisplayPreferencesRepository>(allTypes);
ItemRepositories = GetExports<IItemRepository>(allTypes);
WeatherProviders = GetExports<IWeatherProvider>(allTypes);
IntroProviders = GetExports<IIntroProvider>(allTypes);
PluginConfigurationPages = GetExports<IPluginConfigurationPage>(allTypes);
ImageEnhancers = GetExports<IImageEnhancer>(allTypes).OrderBy(e => e.Priority).ToArray();
PluginFolderCreators = GetExports<IVirtualFolderCreator>(allTypes);
StringFiles = GetExports<LocalizedStringData>(allTypes);
EntityResolvers = GetExports<IBaseItemResolver>(allTypes).OrderBy(e => e.Priority).ToArray();
MetadataProviders = GetExports<BaseMetadataProvider>(allTypes).OrderBy(e => e.Priority).ToArray();
}
/// <summary>
@ -371,24 +358,14 @@ namespace MediaBrowser.Controller
/// <returns>Task.</returns>
protected override async Task ReloadInternal()
{
Logger.Info("Extracting tools");
// Reset these so that they can be lazy loaded again
Users = null;
RootFolder = null;
ReloadResourcePools();
InstallationManager = new InstallationManager(this, ZipClient, Logger);
LibraryManager = new LibraryManager(this, Logger);
UserManager = new UserManager(this, Logger);
FFMpegManager = new FFMpegManager(this, ZipClient, Logger);
ImageManager = new ImageManager(this, Logger);
ProviderManager = new ProviderManager(this, Logger);
UserDataManager = new UserDataManager(this, Logger);
PluginSecurityManager = new PluginSecurityManager(this);
await base.ReloadInternal().ConfigureAwait(false);
ReloadResourcePools();
ReloadFileSystemManager();
await UserManager.RefreshUsersMetadata(CancellationToken.None).ConfigureAwait(false);
@ -456,15 +433,6 @@ namespace MediaBrowser.Controller
DisplayPreferencesRepository = GetRepository(DisplayPreferencesRepositories, Configuration.DisplayPreferencesRepository);
var displayPreferencesRepoTask = DisplayPreferencesRepository.Initialize();
// Sort the resolvers by priority
EntityResolvers = EntityResolvers.OrderBy(e => e.Priority).ToArray();
// Sort the providers by priority
MetadataProviders = MetadataProviders.OrderBy(e => e.Priority).ToArray();
// Sort the image processors by priority
ImageEnhancers = ImageEnhancers.OrderBy(e => e.Priority).ToArray();
await Task.WhenAll(itemRepoTask, userRepoTask, userDataRepoTask, displayPreferencesRepoTask).ConfigureAwait(false);
}
@ -503,7 +471,7 @@ namespace MediaBrowser.Controller
{
DisposeFileSystemManager();
FileSystemManager = new FileSystemManager(this, Logger);
FileSystemManager = new FileSystemManager(this, Logger, TaskManager);
FileSystemManager.StartWatchers();
}

View File

@ -5,6 +5,7 @@ using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using MediaBrowser.Controller.IO;
namespace MediaBrowser.Controller.Library
{

View File

@ -186,9 +186,9 @@ namespace MediaBrowser.Controller.Library
var rootFolder = Kernel.ItemRepository.RetrieveItem(rootFolderPath.GetMBId(typeof(AggregateFolder))) as AggregateFolder ?? (AggregateFolder)GetItem(rootFolderPath);
// Add in the plug-in folders
foreach (var child in Kernel.PluginFolders)
foreach (var child in Kernel.PluginFolderCreators)
{
rootFolder.AddVirtualChild(child);
rootFolder.AddVirtualChild(child.GetFolder());
}
return rootFolder;

View File

@ -1,9 +1,6 @@
using MediaBrowser.Common.Localization;
using System.ComponentModel.Composition;

namespace MediaBrowser.Controller.Localization
{
[Export(typeof(LocalizedStringData))]
public class BaseStrings : LocalizedStringData
{
public BaseStrings()

View File

@ -1,7 +1,7 @@
using System.IO;
using System.Xml.Serialization;
namespace MediaBrowser.Common.Localization
namespace MediaBrowser.Controller.Localization
{
/// <summary>
/// Class LocalizedStringData

View File

@ -1,5 +1,4 @@
using MediaBrowser.Common.Localization;
using MediaBrowser.Model.Logging;
using MediaBrowser.Model.Logging;
using System;
using System.Collections.Concurrent;
using System.Globalization;

View File

@ -64,7 +64,6 @@
<HintPath>..\packages\protobuf-net.2.0.0.621\lib\net40\protobuf-net.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.ComponentModel.Composition" />
<Reference Include="System.Core" />
<Reference Include="System.Data" />
<Reference Include="System.Drawing" />
@ -91,6 +90,7 @@
<Compile Include="Entities\Genre.cs" />
<Compile Include="Entities\ICollectionFolder.cs" />
<Compile Include="Entities\IndexFolder.cs" />
<Compile Include="Entities\IVirtualFolderCreator.cs" />
<Compile Include="Entities\Movies\BoxSet.cs" />
<Compile Include="Entities\Movies\Movie.cs" />
<Compile Include="Entities\Person.cs" />
@ -107,6 +107,7 @@
<Compile Include="Entities\CollectionFolder.cs" />
<Compile Include="Entities\Year.cs" />
<Compile Include="Extensions\XmlExtensions.cs" />
<Compile Include="IO\FileSystem.cs" />
<Compile Include="IO\FileSystemManager.cs" />
<Compile Include="IO\NetworkShares.cs" />
<Compile Include="Library\ChildrenChangedEventArgs.cs" />
@ -117,6 +118,7 @@
<Compile Include="Localization\AURatingsDictionary.cs" />
<Compile Include="Localization\BaseStrings.cs" />
<Compile Include="Localization\GBRatingsDictionary.cs" />
<Compile Include="Localization\LocalizedStringData.cs" />
<Compile Include="Localization\LocalizedStrings.cs" />
<Compile Include="Localization\NLRatingsDictionary.cs" />
<Compile Include="Localization\Ratings.cs" />
@ -134,7 +136,7 @@
<Compile Include="Plugins\IPluginConfigurationPage.cs" />
<Compile Include="Plugins\PluginSecurityManager.cs" />
<Compile Include="Providers\FanartBaseProvider.cs" />
<Compile Include="Providers\BaseImageEnhancer.cs" />
<Compile Include="Providers\IImageEnhancer.cs" />
<Compile Include="Providers\ImagesByNameProvider.cs" />
<Compile Include="Providers\MediaInfo\BaseFFMpegImageProvider.cs" />
<Compile Include="Providers\MediaInfo\BaseFFMpegProvider.cs" />
@ -165,7 +167,7 @@
<Compile Include="Providers\MediaInfo\FFMpegVideoImageProvider.cs" />
<Compile Include="Resolvers\Audio\MusicAlbumResolver.cs" />
<Compile Include="Resolvers\Audio\MusicArtistResolver.cs" />
<Compile Include="Resolvers\BaseResolutionIgnoreRule.cs" />
<Compile Include="Resolvers\IResolutionIgnoreRule.cs" />
<Compile Include="Resolvers\CoreResolutionIgnoreRule.cs" />
<Compile Include="Resolvers\EntityResolutionHelper.cs" />
<Compile Include="Resolvers\LocalTrailerResolver.cs" />
@ -223,8 +225,7 @@
<ItemGroup />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<PropertyGroup>
<PostBuildEvent>
</PostBuildEvent>
<PostBuildEvent>xcopy "$(TargetPath)" "$(SolutionDir)\Nuget\dlls\" /y /d /r /i</PostBuildEvent>
</PropertyGroup>
<PropertyGroup>
<PreBuildEvent>

View File

@ -4,9 +4,9 @@ using MediaBrowser.Common.Kernel;
using MediaBrowser.Common.Serialization;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Entities.Audio;
using MediaBrowser.Controller.Library;
using MediaBrowser.Model.Entities;
using MediaBrowser.Model.IO;
using MediaBrowser.Model.Logging;
using System;
using System.Collections.Generic;
using System.ComponentModel;
@ -17,7 +17,6 @@ using System.Reflection;
using System.Runtime.InteropServices;
using System.Threading;
using System.Threading.Tasks;
using MediaBrowser.Model.Logging;
namespace MediaBrowser.Controller.MediaInfo
{
@ -26,22 +25,6 @@ namespace MediaBrowser.Controller.MediaInfo
/// </summary>
public class FFMpegManager : BaseManager<Kernel>
{
/// <summary>
/// Holds the list of new items to generate chapter image for when the NewItemTimer expires
/// </summary>
private readonly List<Video> _newlyAddedItems = new List<Video>();
/// <summary>
/// The amount of time to wait before generating chapter images
/// </summary>
private const int NewItemDelay = 300000;
/// <summary>
/// The current new item timer
/// </summary>
/// <value>The new item timer.</value>
private Timer NewItemTimer { get; set; }
/// <summary>
/// Gets or sets the video image cache.
/// </summary>
@ -96,73 +79,9 @@ namespace MediaBrowser.Controller.MediaInfo
AudioImageCache = new FileSystemRepository(AudioImagesDataPath);
SubtitleCache = new FileSystemRepository(SubtitleCachePath);
Kernel.LibraryManager.LibraryChanged += LibraryManager_LibraryChanged;
Task.Run(() => VersionedDirectoryPath = GetVersionedDirectoryPath());
}
/// <summary>
/// Handles the LibraryChanged event of the LibraryManager control.
/// </summary>
/// <param name="sender">The source of the event.</param>
/// <param name="e">The <see cref="ChildrenChangedEventArgs" /> instance containing the event data.</param>
void LibraryManager_LibraryChanged(object sender, ChildrenChangedEventArgs e)
{
var videos = e.ItemsAdded.OfType<Video>().ToList();
// Use a timer to prevent lots of these notifications from showing in a short period of time
if (videos.Count > 0)
{
lock (_newlyAddedItems)
{
_newlyAddedItems.AddRange(videos);
if (NewItemTimer == null)
{
NewItemTimer = new Timer(NewItemTimerCallback, null, NewItemDelay, Timeout.Infinite);
}
else
{
NewItemTimer.Change(NewItemDelay, Timeout.Infinite);
}
}
}
}
/// <summary>
/// Called when the new item timer expires
/// </summary>
/// <param name="state">The state.</param>
private async void NewItemTimerCallback(object state)
{
List<Video> newItems;
// Lock the list and release all resources
lock (_newlyAddedItems)
{
newItems = _newlyAddedItems.ToList();
_newlyAddedItems.Clear();
NewItemTimer.Dispose();
NewItemTimer = null;
}
// Limit the number of videos we generate images for
// The idea is to catch new items that are added here and there
// Mass image generation can be left to the scheduled task
foreach (var video in newItems.Where(c => c.Chapters != null).Take(3))
{
try
{
await PopulateChapterImages(video, CancellationToken.None, true, true).ConfigureAwait(false);
}
catch (Exception ex)
{
_logger.ErrorException("Error creating chapter images for {0}", ex, video.Name);
}
}
}
/// <summary>
/// Releases unmanaged and - optionally - managed resources.
/// </summary>
@ -171,15 +90,8 @@ namespace MediaBrowser.Controller.MediaInfo
{
if (dispose)
{
if (NewItemTimer != null)
{
NewItemTimer.Dispose();
}
SetErrorMode(ErrorModes.SYSTEM_DEFAULT);
Kernel.LibraryManager.LibraryChanged -= LibraryManager_LibraryChanged;
AudioImageCache.Dispose();
VideoImageCache.Dispose();
}

View File

@ -1,99 +0,0 @@
using MediaBrowser.Controller.Entities;
using MediaBrowser.Model.Drawing;
using MediaBrowser.Model.Entities;
using System;
using System.Drawing;
using System.Threading.Tasks;
namespace MediaBrowser.Controller.Providers
{
/// <summary>
/// Class BaseImageEnhancer
/// </summary>
public abstract class BaseImageEnhancer : IDisposable
{
/// <summary>
/// Return true only if the given image for the given item will be enhanced by this enhancer.
/// </summary>
/// <param name="item">The item.</param>
/// <param name="imageType">Type of the image.</param>
/// <returns><c>true</c> if this enhancer will enhance the supplied image for the supplied item, <c>false</c> otherwise</returns>
public abstract bool Supports(BaseItem item, ImageType imageType);
/// <summary>
/// Gets the priority or order in which this enhancer should be run.
/// </summary>
/// <value>The priority.</value>
public abstract MetadataProviderPriority Priority { get; }
/// <summary>
/// Return the date of the last configuration change affecting the provided baseitem and image type
/// </summary>
/// <param name="item">The item.</param>
/// <param name="imageType">Type of the image.</param>
/// <returns>Date of last config change</returns>
public virtual DateTime LastConfigurationChange(BaseItem item, ImageType imageType)
{
return DateTime.MinValue;
}
/// <summary>
/// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
/// </summary>
public void Dispose()
{
Dispose(true);
GC.SuppressFinalize(this);
}
/// <summary>
/// Releases unmanaged and - optionally - managed resources.
/// </summary>
/// <param name="dispose"><c>true</c> to release both managed and unmanaged resources; <c>false</c> to release only unmanaged resources.</param>
protected virtual void Dispose(bool dispose)
{
}
/// <summary>
/// Gets the size of the enhanced image.
/// </summary>
/// <param name="item">The item.</param>
/// <param name="imageType">Type of the image.</param>
/// <param name="imageIndex">Index of the image.</param>
/// <param name="originalImageSize">Size of the original image.</param>
/// <returns>ImageSize.</returns>
public virtual ImageSize GetEnhancedImageSize(BaseItem item, ImageType imageType, int imageIndex, ImageSize originalImageSize)
{
return originalImageSize;
}
/// <summary>
/// Enhances the supplied image and returns it
/// </summary>
/// <param name="item">The item.</param>
/// <param name="originalImage">The original image.</param>
/// <param name="imageType">Type of the image.</param>
/// <param name="imageIndex">Index of the image.</param>
/// <returns>Task{System.Drawing.Image}.</returns>
protected abstract Task<Image> EnhanceImageAsyncInternal(BaseItem item, Image originalImage, ImageType imageType, int imageIndex);
/// <summary>
/// Enhances the image async.
/// </summary>
/// <param name="item">The item.</param>
/// <param name="originalImage">The original image.</param>
/// <param name="imageType">Type of the image.</param>
/// <param name="imageIndex">Index of the image.</param>
/// <returns>Task{Image}.</returns>
/// <exception cref="System.ArgumentNullException"></exception>
public Task<Image> EnhanceImageAsync(BaseItem item, Image originalImage, ImageType imageType, int imageIndex)
{
if (item == null || originalImage == null)
{
throw new ArgumentNullException();
}
return EnhanceImageAsyncInternal(item, originalImage, imageType, imageIndex);
}
}
}

View File

@ -1,7 +1,6 @@
using MediaBrowser.Controller.Entities;
using MediaBrowser.Model.Entities;
using System;
using System.ComponentModel.Composition;
using System.IO;
using System.Threading;
using System.Threading.Tasks;
@ -11,7 +10,6 @@ namespace MediaBrowser.Controller.Providers
/// <summary>
/// Provides metadata for Folders and all subclasses by parsing folder.xml
/// </summary>
[Export(typeof(BaseMetadataProvider))]
public class FolderProviderFromXml : BaseMetadataProvider
{
/// <summary>

View File

@ -0,0 +1,55 @@
using MediaBrowser.Controller.Entities;
using MediaBrowser.Model.Drawing;
using MediaBrowser.Model.Entities;
using System;
using System.Drawing;
using System.Threading.Tasks;
namespace MediaBrowser.Controller.Providers
{
public interface IImageEnhancer
{
/// <summary>
/// Return true only if the given image for the given item will be enhanced by this enhancer.
/// </summary>
/// <param name="item">The item.</param>
/// <param name="imageType">Type of the image.</param>
/// <returns><c>true</c> if this enhancer will enhance the supplied image for the supplied item, <c>false</c> otherwise</returns>
bool Supports(BaseItem item, ImageType imageType);
/// <summary>
/// Gets the priority or order in which this enhancer should be run.
/// </summary>
/// <value>The priority.</value>
MetadataProviderPriority Priority { get; }
/// <summary>
/// Return the date of the last configuration change affecting the provided baseitem and image type
/// </summary>
/// <param name="item">The item.</param>
/// <param name="imageType">Type of the image.</param>
/// <returns>Date of last config change</returns>
DateTime LastConfigurationChange(BaseItem item, ImageType imageType);
/// <summary>
/// Gets the size of the enhanced image.
/// </summary>
/// <param name="item">The item.</param>
/// <param name="imageType">Type of the image.</param>
/// <param name="imageIndex">Index of the image.</param>
/// <param name="originalImageSize">Size of the original image.</param>
/// <returns>ImageSize.</returns>
ImageSize GetEnhancedImageSize(BaseItem item, ImageType imageType, int imageIndex, ImageSize originalImageSize);
/// <summary>
/// Enhances the image async.
/// </summary>
/// <param name="item">The item.</param>
/// <param name="originalImage">The original image.</param>
/// <param name="imageType">Type of the image.</param>
/// <param name="imageIndex">Index of the image.</param>
/// <returns>Task{Image}.</returns>
/// <exception cref="System.ArgumentNullException"></exception>
Task<Image> EnhanceImageAsync(BaseItem item, Image originalImage, ImageType imageType, int imageIndex);
}
}

View File

@ -3,7 +3,6 @@ using MediaBrowser.Controller.Entities;
using MediaBrowser.Model.Entities;
using System;
using System.Collections.Generic;
using System.ComponentModel.Composition;
using System.IO;
using System.Linq;
using System.Threading;
@ -14,7 +13,6 @@ namespace MediaBrowser.Controller.Providers
/// <summary>
/// Provides images for all types by looking for standard images - folder, backdrop, logo, etc.
/// </summary>
[Export(typeof(BaseMetadataProvider))]
public class ImageFromMediaLocationProvider : BaseMetadataProvider
{
/// <summary>

View File

@ -1,9 +1,8 @@
using System.Globalization;
using MediaBrowser.Common.IO;
using MediaBrowser.Common.Win32;
using MediaBrowser.Common.Win32;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.IO;
using System;
using System.ComponentModel.Composition;
using System.Globalization;
using System.IO;
using System.Linq;
@ -12,7 +11,6 @@ namespace MediaBrowser.Controller.Providers
/// <summary>
/// Provides images for generic types by looking for standard images in the IBN
/// </summary>
[Export(typeof(BaseMetadataProvider))]
public class ImagesByNameProvider : ImageFromMediaLocationProvider
{
/// <summary>

View File

@ -2,7 +2,6 @@
using MediaBrowser.Controller.Entities.Audio;
using MediaBrowser.Model.Entities;
using System;
using System.ComponentModel.Composition;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
@ -12,7 +11,6 @@ namespace MediaBrowser.Controller.Providers.MediaInfo
/// <summary>
/// Uses ffmpeg to create video images
/// </summary>
[Export(typeof(BaseMetadataProvider))]
public class FFMpegAudioImageProvider : BaseFFMpegImageProvider<Audio>
{

View File

@ -2,7 +2,6 @@
using MediaBrowser.Controller.Entities;
using MediaBrowser.Model.Entities;
using System;
using System.ComponentModel.Composition;
using System.Threading;
using System.Threading.Tasks;
@ -11,9 +10,22 @@ namespace MediaBrowser.Controller.Providers.MediaInfo
/// <summary>
/// Uses ffmpeg to create video images
/// </summary>
[Export(typeof(BaseMetadataProvider))]
public class FFMpegVideoImageProvider : BaseFFMpegImageProvider<Video>
{
/// <summary>
/// The _iso manager
/// </summary>
private readonly IIsoManager _isoManager;
/// <summary>
/// Initializes a new instance of the <see cref="FFMpegVideoImageProvider" /> class.
/// </summary>
/// <param name="isoManager">The iso manager.</param>
public FFMpegVideoImageProvider(IIsoManager isoManager)
{
_isoManager = isoManager;
}
/// <summary>
/// Supportses the specified item.
/// </summary>
@ -30,7 +42,7 @@ namespace MediaBrowser.Controller.Providers.MediaInfo
if (video != null)
{
if (video.VideoType == VideoType.Iso && video.IsoType.HasValue && Kernel.Instance.IsoManager.CanMount(item.Path))
if (video.VideoType == VideoType.Iso && video.IsoType.HasValue && _isoManager.CanMount(item.Path))
{
return true;
}
@ -82,7 +94,7 @@ namespace MediaBrowser.Controller.Providers.MediaInfo
{
if (item.VideoType == VideoType.Iso)
{
return Kernel.Instance.IsoManager.Mount(item.Path, cancellationToken);
return _isoManager.Mount(item.Path, cancellationToken);
}
return NullMountTaskResult;

View File

@ -5,7 +5,6 @@ using MediaBrowser.Controller.MediaInfo;
using MediaBrowser.Model.Entities;
using System;
using System.Collections.Generic;
using System.ComponentModel.Composition;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
@ -15,7 +14,6 @@ namespace MediaBrowser.Controller.Providers.MediaInfo
/// <summary>
/// Extracts audio information using ffprobe
/// </summary>
[Export(typeof(BaseMetadataProvider))]
public class FFProbeAudioInfoProvider : BaseFFProbeProvider<Audio>
{
/// <summary>

View File

@ -6,7 +6,6 @@ using MediaBrowser.Model.Entities;
using MediaBrowser.Model.MediaInfo;
using System;
using System.Collections.Generic;
using System.ComponentModel.Composition;
using System.IO;
using System.Linq;
using System.Threading;
@ -17,7 +16,6 @@ namespace MediaBrowser.Controller.Providers.MediaInfo
/// <summary>
/// Extracts video information using ffprobe
/// </summary>
[Export(typeof(BaseMetadataProvider))]
public class FFProbeVideoInfoProvider : BaseFFProbeProvider<Video>
{
/// <summary>
@ -32,13 +30,18 @@ namespace MediaBrowser.Controller.Providers.MediaInfo
/// <value>The bluray examiner.</value>
private IBlurayExaminer BlurayExaminer { get; set; }
/// <summary>
/// The _iso manager
/// </summary>
private readonly IIsoManager _isoManager;
/// <summary>
/// Initializes a new instance of the <see cref="FFProbeVideoInfoProvider" /> class.
/// </summary>
/// <param name="isoManager">The iso manager.</param>
/// <param name="blurayExaminer">The bluray examiner.</param>
/// <exception cref="System.ArgumentNullException">blurayExaminer</exception>
[ImportingConstructor]
public FFProbeVideoInfoProvider([Import("blurayExaminer")] IBlurayExaminer blurayExaminer)
public FFProbeVideoInfoProvider(IIsoManager isoManager, IBlurayExaminer blurayExaminer)
: base()
{
if (blurayExaminer == null)
@ -47,6 +50,7 @@ namespace MediaBrowser.Controller.Providers.MediaInfo
}
BlurayExaminer = blurayExaminer;
_isoManager = isoManager;
BdInfoCache = new FileSystemRepository(Path.Combine(Kernel.Instance.ApplicationPaths.CachePath, "bdinfo"));
}
@ -76,7 +80,7 @@ namespace MediaBrowser.Controller.Providers.MediaInfo
{
if (video.VideoType == VideoType.Iso)
{
return Kernel.Instance.IsoManager.CanMount(item.Path);
return _isoManager.CanMount(item.Path);
}
return video.VideoType == VideoType.VideoFile || video.VideoType == VideoType.Dvd || video.VideoType == VideoType.BluRay;
@ -101,7 +105,7 @@ namespace MediaBrowser.Controller.Providers.MediaInfo
{
PopulateDvdStreamFiles(item, mount);
}
base.OnPreFetch(item, mount);
}
@ -115,7 +119,7 @@ namespace MediaBrowser.Controller.Providers.MediaInfo
{
if (item.VideoType == VideoType.Iso)
{
return Kernel.Instance.IsoManager.Mount(item.Path, cancellationToken);
return _isoManager.Mount(item.Path, cancellationToken);
}
return base.MountIsoIfNeeded(item, cancellationToken);

View File

@ -4,7 +4,6 @@ using MediaBrowser.Controller.Entities.Movies;
using MediaBrowser.Model.Entities;
using MediaBrowser.Model.Net;
using System;
using System.ComponentModel.Composition;
using System.IO;
using System.Threading;
using System.Threading.Tasks;
@ -15,7 +14,6 @@ namespace MediaBrowser.Controller.Providers.Movies
/// <summary>
/// Class FanArtMovieProvider
/// </summary>
[Export(typeof(BaseMetadataProvider))]
class FanArtMovieProvider : FanartBaseProvider
{
/// <summary>

View File

@ -7,7 +7,6 @@ using MediaBrowser.Model.Logging;
using MediaBrowser.Model.Net;
using System;
using System.Collections.Generic;
using System.ComponentModel.Composition;
using System.Globalization;
using System.IO;
using System.Linq;
@ -29,7 +28,6 @@ namespace MediaBrowser.Controller.Providers.Movies
/// <summary>
/// Class MovieDbProvider
/// </summary>
[Export(typeof(BaseMetadataProvider))]
public class MovieDbProvider : BaseMetadataProvider
{
/// <summary>

View File

@ -1,7 +1,6 @@
using MediaBrowser.Common.Serialization;
using MediaBrowser.Controller.Entities;
using System;
using System.ComponentModel.Composition;
using System.IO;
using System.Threading;
using System.Threading.Tasks;
@ -11,7 +10,6 @@ namespace MediaBrowser.Controller.Providers.Movies
/// <summary>
/// Class MovieProviderFromJson
/// </summary>
[Export(typeof(BaseMetadataProvider))]
public class MovieProviderFromJson : MovieDbProvider
{
/// <summary>

View File

@ -1,7 +1,6 @@
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Entities.Movies;
using System;
using System.ComponentModel.Composition;
using System.IO;
using System.Threading;
using System.Threading.Tasks;
@ -11,7 +10,6 @@ namespace MediaBrowser.Controller.Providers.Movies
/// <summary>
/// Class MovieProviderFromXml
/// </summary>
[Export(typeof(BaseMetadataProvider))]
public class MovieProviderFromXml : BaseMetadataProvider
{
/// <summary>

View File

@ -1,7 +1,6 @@
using MediaBrowser.Common.Serialization;
using MediaBrowser.Controller.Entities;
using System;
using System.ComponentModel.Composition;
using System.IO;
using System.Threading;
using System.Threading.Tasks;
@ -11,7 +10,6 @@ namespace MediaBrowser.Controller.Providers.Movies
/// <summary>
/// Class PersonProviderFromJson
/// </summary>
[Export(typeof(BaseMetadataProvider))]
class PersonProviderFromJson : TmdbPersonProvider
{
/// <summary>

View File

@ -4,7 +4,6 @@ using MediaBrowser.Model.Entities;
using MediaBrowser.Model.Net;
using System;
using System.Collections.Generic;
using System.ComponentModel.Composition;
using System.Globalization;
using System.IO;
using System.Linq;
@ -17,7 +16,6 @@ namespace MediaBrowser.Controller.Providers.Movies
/// <summary>
/// Class TmdbPersonProvider
/// </summary>
[Export(typeof(BaseMetadataProvider))]
public class TmdbPersonProvider : BaseMetadataProvider
{
/// <summary>

View File

@ -1,7 +1,6 @@
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Entities.Audio;
using MediaBrowser.Controller.Entities.TV;
using System.ComponentModel.Composition;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
@ -11,7 +10,6 @@ namespace MediaBrowser.Controller.Providers
/// <summary>
/// Class SortNameProvider
/// </summary>
[Export(typeof(BaseMetadataProvider))]
public class SortNameProvider : BaseMetadataProvider
{
/// <summary>

View File

@ -2,7 +2,6 @@
using MediaBrowser.Controller.Entities.TV;
using MediaBrowser.Model.Entities;
using System;
using System.ComponentModel.Composition;
using System.IO;
using System.Threading;
using System.Threading.Tasks;
@ -12,7 +11,6 @@ namespace MediaBrowser.Controller.Providers.TV
/// <summary>
/// Class EpisodeImageFromMediaLocationProvider
/// </summary>
[Export(typeof(BaseMetadataProvider))]
public class EpisodeImageFromMediaLocationProvider : BaseMetadataProvider
{
/// <summary>

View File

@ -2,7 +2,6 @@
using MediaBrowser.Controller.Entities.TV;
using MediaBrowser.Model.Entities;
using System;
using System.ComponentModel.Composition;
using System.IO;
using System.Threading;
using System.Threading.Tasks;
@ -12,7 +11,6 @@ namespace MediaBrowser.Controller.Providers.TV
/// <summary>
/// Class EpisodeProviderFromXml
/// </summary>
[Export(typeof(BaseMetadataProvider))]
public class EpisodeProviderFromXml : BaseMetadataProvider
{
/// <summary>

View File

@ -4,7 +4,6 @@ using MediaBrowser.Controller.Entities.TV;
using MediaBrowser.Model.Entities;
using MediaBrowser.Model.Net;
using System;
using System.ComponentModel.Composition;
using System.IO;
using System.Threading;
using System.Threading.Tasks;
@ -12,7 +11,6 @@ using System.Xml;
namespace MediaBrowser.Controller.Providers.TV
{
[Export(typeof(BaseMetadataProvider))]
class FanArtTVProvider : FanartBaseProvider
{
protected string FanArtBaseUrl = "http://api.fanart.tv/webservice/series/{0}/{1}/xml/all/1/1";

View File

@ -5,7 +5,6 @@ using MediaBrowser.Controller.Resolvers.TV;
using MediaBrowser.Model.Entities;
using MediaBrowser.Model.Net;
using System;
using System.ComponentModel.Composition;
using System.IO;
using System.Linq;
using System.Threading;
@ -18,7 +17,6 @@ namespace MediaBrowser.Controller.Providers.TV
/// <summary>
/// Class RemoteEpisodeProvider
/// </summary>
[Export(typeof(BaseMetadataProvider))]
class RemoteEpisodeProvider : BaseMetadataProvider
{

View File

@ -5,7 +5,6 @@ using MediaBrowser.Model.Entities;
using MediaBrowser.Model.Net;
using System;
using System.Collections.Generic;
using System.ComponentModel.Composition;
using System.IO;
using System.Threading;
using System.Threading.Tasks;
@ -16,7 +15,6 @@ namespace MediaBrowser.Controller.Providers.TV
/// <summary>
/// Class RemoteSeasonProvider
/// </summary>
[Export(typeof(BaseMetadataProvider))]
class RemoteSeasonProvider : BaseMetadataProvider
{

View File

@ -7,7 +7,6 @@ using MediaBrowser.Model.Entities;
using MediaBrowser.Model.Net;
using System;
using System.Collections.Generic;
using System.ComponentModel.Composition;
using System.IO;
using System.Net;
using System.Text;
@ -20,7 +19,6 @@ namespace MediaBrowser.Controller.Providers.TV
/// <summary>
/// Class RemoteSeriesProvider
/// </summary>
[Export(typeof(BaseMetadataProvider))]
class RemoteSeriesProvider : BaseMetadataProvider
{

View File

@ -2,7 +2,6 @@
using MediaBrowser.Controller.Entities.TV;
using MediaBrowser.Model.Entities;
using System;
using System.ComponentModel.Composition;
using System.IO;
using System.Threading;
using System.Threading.Tasks;
@ -12,7 +11,6 @@ namespace MediaBrowser.Controller.Providers.TV
/// <summary>
/// Class SeriesProviderFromXml
/// </summary>
[Export(typeof(BaseMetadataProvider))]
public class SeriesProviderFromXml : BaseMetadataProvider
{
/// <summary>

Some files were not shown because too many files have changed in this diff Show More