using System; using System.Collections.Generic; using System.Globalization; using System.Linq; using System.Threading; using System.Threading.Tasks; using MediaBrowser.Model.IO; namespace Emby.Server.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. /// . public Task Mount(string isoPath, CancellationToken cancellationToken) { if (string.IsNullOrEmpty(isoPath)) { throw new ArgumentNullException(nameof(isoPath)); } var mounter = _mounters.FirstOrDefault(i => i.CanMount(isoPath)); if (mounter == null) { throw new ArgumentException( string.Format( CultureInfo.InvariantCulture, "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); } } }