Minor refactoring. Use static Log class instead of ILogger where appropriate.

This commit is contained in:
Ben Olden-Cooligan 2015-08-03 06:42:28 -04:00
parent 68d228d019
commit c1df392528
5 changed files with 11 additions and 13 deletions

View File

@ -49,7 +49,6 @@ namespace NAPS2.Console
private readonly IScanPerformer scanPerformer;
private readonly IErrorOutput errorOutput;
private readonly IScannedImageImporter scannedImageImporter;
private readonly ILogger logger;
private readonly IUserConfigManager userConfigManager;
private readonly PdfSettingsContainer pdfSettingsContainer;
private readonly FileNameSubstitution fileNameSubstitution;
@ -60,7 +59,7 @@ namespace NAPS2.Console
private int pagesScanned;
private int totalPagesScanned;
public AutomatedScanning(AutomatedScanningOptions options, ImageSaver imageSaver, IPdfExporter pdfExporter, IProfileManager profileManager, IScanPerformer scanPerformer, IErrorOutput errorOutput, IEmailer emailer, IScannedImageImporter scannedImageImporter, ILogger logger, IUserConfigManager userConfigManager, PdfSettingsContainer pdfSettingsContainer, FileNameSubstitution fileNameSubstitution, ImageSettingsContainer imageSettingsContainer)
public AutomatedScanning(AutomatedScanningOptions options, ImageSaver imageSaver, IPdfExporter pdfExporter, IProfileManager profileManager, IScanPerformer scanPerformer, IErrorOutput errorOutput, IEmailer emailer, IScannedImageImporter scannedImageImporter, IUserConfigManager userConfigManager, PdfSettingsContainer pdfSettingsContainer, FileNameSubstitution fileNameSubstitution, ImageSettingsContainer imageSettingsContainer)
{
this.options = options;
this.imageSaver = imageSaver;
@ -70,7 +69,6 @@ namespace NAPS2.Console
this.errorOutput = errorOutput;
this.emailer = emailer;
this.scannedImageImporter = scannedImageImporter;
this.logger = logger;
this.userConfigManager = userConfigManager;
this.pdfSettingsContainer = pdfSettingsContainer;
this.fileNameSubstitution = fileNameSubstitution;
@ -155,7 +153,7 @@ namespace NAPS2.Console
}
catch (Exception ex)
{
logger.ErrorException(string.Format(ConsoleResources.ErrorImporting, filePath), ex);
Log.ErrorException(string.Format(ConsoleResources.ErrorImporting, filePath), ex);
errorOutput.DisplayError(string.Format(ConsoleResources.ErrorImporting, filePath));
continue;
}
@ -343,7 +341,7 @@ namespace NAPS2.Console
}
catch (IOException ex)
{
logger.ErrorException(ConsoleResources.ErrorSaving, ex);
Log.ErrorException(ConsoleResources.ErrorSaving, ex);
errorOutput.DisplayError(ConsoleResources.ErrorSaving);
}
}
@ -382,7 +380,7 @@ namespace NAPS2.Console
}
catch (Exception ex)
{
logger.ErrorException(ConsoleResources.CouldntLoadEncryptionConfig, ex);
Log.ErrorException(ConsoleResources.CouldntLoadEncryptionConfig, ex);
errorOutput.DisplayError(ConsoleResources.CouldntLoadEncryptionConfig);
}
}

View File

@ -47,8 +47,7 @@ namespace NAPS2.Console
}
catch (Exception ex)
{
KernelManager.Kernel.Get<ILogger>()
.FatalException("An error occurred that caused the console application to close.", ex);
Log.FatalException("An error occurred that caused the console application to close.", ex);
System.Console.WriteLine(ConsoleResources.UnexpectedError);
}
finally

View File

@ -29,10 +29,6 @@ namespace NAPS2.Scan
{
public abstract class ScanDriverBase : IScanDriver
{
protected ScanDriverBase()
{
}
public abstract string DriverName { get; }
public ExtendedScanSettings ScanSettings { get; set; }

View File

@ -28,5 +28,10 @@ namespace NAPS2.Util
{
_logger.ErrorException(message, exception);
}
public static void FatalException(string message, Exception exception)
{
_logger.FatalException(message, exception);
}
}
}

View File

@ -52,7 +52,7 @@ namespace NAPS2
private static void UnhandledException(object sender, ThreadExceptionEventArgs threadExceptionEventArgs)
{
KernelManager.Kernel.Get<ILogger>().FatalException("An error occurred that caused the application to close.", threadExceptionEventArgs.Exception);
Log.FatalException("An error occurred that caused the application to close.", threadExceptionEventArgs.Exception);
}
}
}