From 155a6e96346e0cb3d9ab6f5372fa29b46ebaee89 Mon Sep 17 00:00:00 2001 From: Rob Mensching Date: Tue, 19 Dec 2017 12:25:40 -0800 Subject: Integrate simplified message handling --- src/WixToolset.Core/Bind/TransferFilesCommand.cs | 26 ++++++++++++++---------- 1 file changed, 15 insertions(+), 11 deletions(-) (limited to 'src/WixToolset.Core/Bind/TransferFilesCommand.cs') diff --git a/src/WixToolset.Core/Bind/TransferFilesCommand.cs b/src/WixToolset.Core/Bind/TransferFilesCommand.cs index f116569c..68d8b129 100644 --- a/src/WixToolset.Core/Bind/TransferFilesCommand.cs +++ b/src/WixToolset.Core/Bind/TransferFilesCommand.cs @@ -9,18 +9,22 @@ namespace WixToolset.Core.Bind using WixToolset.Data; using WixToolset.Data.Bind; using WixToolset.Extensibility; + using WixToolset.Extensibility.Services; internal class TransferFilesCommand { - public TransferFilesCommand(IEnumerable bindPaths, IEnumerable extensions, IEnumerable fileTransfers, bool suppressAclReset) + public TransferFilesCommand(IMessaging messaging, IEnumerable bindPaths, IEnumerable extensions, IEnumerable fileTransfers, bool suppressAclReset) { this.FileResolver = new FileResolver(bindPaths, extensions); + this.Messaging = messaging; this.FileTransfers = fileTransfers; this.SuppressAclReset = suppressAclReset; } private FileResolver FileResolver { get; } + private IMessaging Messaging { get; } + private IEnumerable FileTransfers { get; } private bool SuppressAclReset { get; } @@ -47,12 +51,12 @@ namespace WixToolset.Core.Bind { if (fileTransfer.Move) { - Messaging.Instance.OnMessage(WixVerboses.MoveFile(fileSource, fileTransfer.Destination)); + this.Messaging.Write(VerboseMessages.MoveFile(fileSource, fileTransfer.Destination)); this.TransferFile(true, fileSource, fileTransfer.Destination); } else { - Messaging.Instance.OnMessage(WixVerboses.CopyFile(fileSource, fileTransfer.Destination)); + this.Messaging.Write(VerboseMessages.CopyFile(fileSource, fileTransfer.Destination)); this.TransferFile(false, fileSource, fileTransfer.Destination); } @@ -61,7 +65,7 @@ namespace WixToolset.Core.Bind } catch (FileNotFoundException e) { - throw new WixFileNotFoundException(e.FileName); + throw new WixFileNotFoundException(fileTransfer.SourceLineNumbers, e.FileName); } catch (DirectoryNotFoundException) { @@ -72,7 +76,7 @@ namespace WixToolset.Core.Bind } string directory = Path.GetDirectoryName(fileTransfer.Destination); - Messaging.Instance.OnMessage(WixVerboses.CreateDirectory(directory)); + this.Messaging.Write(VerboseMessages.CreateDirectory(directory)); Directory.CreateDirectory(directory); retry = true; } @@ -86,7 +90,7 @@ namespace WixToolset.Core.Bind if (File.Exists(fileTransfer.Destination)) { - Messaging.Instance.OnMessage(WixVerboses.RemoveDestinationFile(fileTransfer.Destination)); + this.Messaging.Write(VerboseMessages.RemoveDestinationFile(fileTransfer.Destination)); // try to ensure the file is not read-only FileAttributes attributes = File.GetAttributes(fileTransfer.Destination); @@ -96,7 +100,7 @@ namespace WixToolset.Core.Bind } catch (ArgumentException) // thrown for unauthorized access errors { - throw new WixException(WixErrors.UnauthorizedAccess(fileTransfer.Destination)); + throw new WixException(ErrorMessages.UnauthorizedAccess(fileTransfer.Destination)); } // try to delete the file @@ -106,7 +110,7 @@ namespace WixToolset.Core.Bind } catch (IOException) { - throw new WixException(WixErrors.FileInUse(null, fileTransfer.Destination)); + throw new WixException(ErrorMessages.FileInUse(null, fileTransfer.Destination)); } retry = true; @@ -126,7 +130,7 @@ namespace WixToolset.Core.Bind if (File.Exists(fileTransfer.Destination)) { - Messaging.Instance.OnMessage(WixVerboses.RemoveDestinationFile(fileTransfer.Destination)); + this.Messaging.Write(VerboseMessages.RemoveDestinationFile(fileTransfer.Destination)); // ensure the file is not read-only, then delete it FileAttributes attributes = File.GetAttributes(fileTransfer.Destination); @@ -137,7 +141,7 @@ namespace WixToolset.Core.Bind } catch (IOException) { - throw new WixException(WixErrors.FileInUse(null, fileTransfer.Destination)); + throw new WixException(ErrorMessages.FileInUse(null, fileTransfer.Destination)); } retry = true; @@ -168,7 +172,7 @@ namespace WixToolset.Core.Bind } catch { - Messaging.Instance.OnMessage(WixWarnings.UnableToResetAcls()); + this.Messaging.Write(WarningMessages.UnableToResetAcls()); } } } -- cgit v1.2.3-55-g6feb