From 058f9c11ff4e56c8359c4fae697616ddc54ec4c9 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Fri, 9 Aug 2013 21:40:52 -0400 Subject: [PATCH] update to re-worked iso manager --- .../IO/IsoManager.cs | 75 +++++++++++++++++++ ...MediaBrowser.Common.Implementations.csproj | 1 + .../ApplicationHost.cs | 9 ++- .../MediaBrowser.ServerApplication.csproj | 10 ++- .../packages.config | 2 +- 5 files changed, 91 insertions(+), 6 deletions(-) create mode 100644 MediaBrowser.Common.Implementations/IO/IsoManager.cs diff --git a/MediaBrowser.Common.Implementations/IO/IsoManager.cs b/MediaBrowser.Common.Implementations/IO/IsoManager.cs new file mode 100644 index 000000000..de88ddada --- /dev/null +++ b/MediaBrowser.Common.Implementations/IO/IsoManager.cs @@ -0,0 +1,75 @@ +using MediaBrowser.Model.IO; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading; +using System.Threading.Tasks; + +namespace MediaBrowser.Common.Implementations.IO +{ + /// + /// Class IsoManager + /// + public class IsoManager : IIsoManager + { + /// + /// The _mounters + /// + private readonly List _mounters = new List(); + + /// + /// Mounts the specified iso path. + /// + /// The iso path. + /// The cancellation token. + /// IsoMount. + /// isoPath + /// + public Task Mount(string isoPath, CancellationToken cancellationToken) + { + if (string.IsNullOrEmpty(isoPath)) + { + throw new ArgumentNullException("isoPath"); + } + + var mounter = _mounters.FirstOrDefault(i => i.CanMount(isoPath)); + + if (mounter == null) + { + throw new ArgumentException(string.Format("No mounters are able to mount {0}", isoPath)); + } + + return mounter.Mount(isoPath, cancellationToken); + } + + /// + /// Determines whether this instance can mount the specified path. + /// + /// The path. + /// true if this instance can mount the specified path; otherwise, false. + public bool CanMount(string path) + { + return _mounters.Any(i => i.CanMount(path)); + } + + /// + /// Adds the parts. + /// + /// The mounters. + public void AddParts(IEnumerable mounters) + { + _mounters.AddRange(mounters); + } + + /// + /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. + /// + public void Dispose() + { + foreach (var mounter in _mounters) + { + mounter.Dispose(); + } + } + } +} diff --git a/MediaBrowser.Common.Implementations/MediaBrowser.Common.Implementations.csproj b/MediaBrowser.Common.Implementations/MediaBrowser.Common.Implementations.csproj index 07e7869c7..1e45c1869 100644 --- a/MediaBrowser.Common.Implementations/MediaBrowser.Common.Implementations.csproj +++ b/MediaBrowser.Common.Implementations/MediaBrowser.Common.Implementations.csproj @@ -66,6 +66,7 @@ + diff --git a/MediaBrowser.ServerApplication/ApplicationHost.cs b/MediaBrowser.ServerApplication/ApplicationHost.cs index 1ef3adb13..3d640190c 100644 --- a/MediaBrowser.ServerApplication/ApplicationHost.cs +++ b/MediaBrowser.ServerApplication/ApplicationHost.cs @@ -4,6 +4,7 @@ using MediaBrowser.Common.Configuration; using MediaBrowser.Common.Constants; using MediaBrowser.Common.Extensions; using MediaBrowser.Common.Implementations; +using MediaBrowser.Common.Implementations.IO; using MediaBrowser.Common.Implementations.ScheduledTasks; using MediaBrowser.Common.Implementations.Updates; using MediaBrowser.Common.IO; @@ -161,6 +162,8 @@ namespace MediaBrowser.ServerApplication /// The media encoder. private IMediaEncoder MediaEncoder { get; set; } + private IIsoManager IsoManager { get; set; } + private ILocalizationManager LocalizationManager { get; set; } /// @@ -238,7 +241,9 @@ namespace MediaBrowser.ServerApplication RegisterSingleInstance(() => new AlchemyServer(Logger)); - //RegisterSingleInstance(() => new PismoIsoManager(Logger)); + IsoManager = new IsoManager(); + RegisterSingleInstance(IsoManager); + RegisterSingleInstance(() => new BdInfoExaminer()); ZipClient = new DotNetZipClient(); @@ -442,6 +447,8 @@ namespace MediaBrowser.ServerApplication GetExports()); ProviderManager.AddParts(GetExports().ToArray()); + + IsoManager.AddParts(GetExports().ToArray()); } /// diff --git a/MediaBrowser.ServerApplication/MediaBrowser.ServerApplication.csproj b/MediaBrowser.ServerApplication/MediaBrowser.ServerApplication.csproj index e3b5677f9..04d20cb3d 100644 --- a/MediaBrowser.ServerApplication/MediaBrowser.ServerApplication.csproj +++ b/MediaBrowser.ServerApplication/MediaBrowser.ServerApplication.csproj @@ -126,8 +126,9 @@ ..\packages\MahApps.Metro.0.11.0.17-ALPHA\lib\net45\MahApps.Metro.dll - - ..\packages\MediaBrowser.IsoMounting.3.0.55\lib\net45\MediaBrowser.IsoMounter.dll + + False + ..\packages\MediaBrowser.IsoMounting.3.0.56\lib\net45\MediaBrowser.IsoMounter.dll False @@ -137,8 +138,9 @@ False ..\packages\NLog.2.0.1.2\lib\net45\NLog.dll - - ..\packages\MediaBrowser.IsoMounting.3.0.55\lib\net45\pfmclrapi.dll + + False + ..\packages\MediaBrowser.IsoMounting.3.0.56\lib\net45\pfmclrapi.dll False diff --git a/MediaBrowser.ServerApplication/packages.config b/MediaBrowser.ServerApplication/packages.config index 82f63c52c..80c84d311 100644 --- a/MediaBrowser.ServerApplication/packages.config +++ b/MediaBrowser.ServerApplication/packages.config @@ -3,7 +3,7 @@ - +