From 931c0ea455161b8ee00005a0ffd1f8afab41f7bb Mon Sep 17 00:00:00 2001 From: LukePulverenti Date: Thu, 21 Feb 2013 16:39:53 -0500 Subject: more dependancy injection --- MediaBrowser.Controller/Drawing/ImageManager.cs | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'MediaBrowser.Controller/Drawing/ImageManager.cs') diff --git a/MediaBrowser.Controller/Drawing/ImageManager.cs b/MediaBrowser.Controller/Drawing/ImageManager.cs index c033fd1f4..2077525a3 100644 --- a/MediaBrowser.Controller/Drawing/ImageManager.cs +++ b/MediaBrowser.Controller/Drawing/ImageManager.cs @@ -15,6 +15,7 @@ using System.Drawing.Imaging; using System.IO; using System.Linq; using System.Threading.Tasks; +using MediaBrowser.Model.Logging; namespace MediaBrowser.Controller.Drawing { @@ -51,13 +52,21 @@ namespace MediaBrowser.Controller.Drawing /// private readonly ConcurrentDictionary> _cachedImagedSizes = new ConcurrentDictionary>(); + /// + /// The _logger + /// + private readonly ILogger _logger; + /// /// Initializes a new instance of the class. /// /// The kernel. - public ImageManager(Kernel kernel) + /// The logger. + public ImageManager(Kernel kernel, ILogger logger) : base(kernel) { + _logger = logger; + ImageSizeCache = new FileSystemRepository(Path.Combine(Kernel.ApplicationPaths.ImageCachePath, "image-sizes")); ResizedImageCache = new FileSystemRepository(Path.Combine(Kernel.ApplicationPaths.ImageCachePath, "resized-images")); CroppedImageCache = new FileSystemRepository(Path.Combine(Kernel.ApplicationPaths.ImageCachePath, "cropped-images")); @@ -103,7 +112,7 @@ namespace MediaBrowser.Controller.Drawing catch (Exception ex) { // We have to have a catch-all here because some of the .net image methods throw a plain old Exception - Logger.ErrorException("Error cropping image", ex); + _logger.ErrorException("Error cropping image", ex); } } @@ -121,7 +130,7 @@ namespace MediaBrowser.Controller.Drawing } catch { - Logger.Error("Error enhancing image"); + _logger.Error("Error enhancing image"); } var originalImageSize = await GetImageSize(originalImagePath, dateModified).ConfigureAwait(false); @@ -276,7 +285,7 @@ namespace MediaBrowser.Controller.Drawing // Cache file doesn't exist no biggie } - var size = ImageHeader.GetDimensions(imagePath, Logger); + var size = ImageHeader.GetDimensions(imagePath, _logger); var imageSize = new ImageSize { Width = size.Width, Height = size.Height }; -- cgit v1.2.3