diff options
author | Rob Mensching <rob@firegiant.com> | 2017-12-19 12:25:40 -0800 |
---|---|---|
committer | Rob Mensching <rob@firegiant.com> | 2017-12-19 12:25:40 -0800 |
commit | 155a6e96346e0cb3d9ab6f5372fa29b46ebaee89 (patch) | |
tree | 59d1f151bfde8068b6014b05b5c8cfea3402c974 /src/WixToolset.Core/Bind | |
parent | 6f1665ed759b31bd095f186f9239232c653597cd (diff) | |
download | wix-155a6e96346e0cb3d9ab6f5372fa29b46ebaee89.tar.gz wix-155a6e96346e0cb3d9ab6f5372fa29b46ebaee89.tar.bz2 wix-155a6e96346e0cb3d9ab6f5372fa29b46ebaee89.zip |
Integrate simplified message handling
Diffstat (limited to 'src/WixToolset.Core/Bind')
-rw-r--r-- | src/WixToolset.Core/Bind/FileResolver.cs | 2 | ||||
-rw-r--r-- | src/WixToolset.Core/Bind/ResolveDelayedFieldsCommand.cs | 10 | ||||
-rw-r--r-- | src/WixToolset.Core/Bind/ResolveFieldsCommand.cs | 9 | ||||
-rw-r--r-- | src/WixToolset.Core/Bind/TransferFilesCommand.cs | 26 |
4 files changed, 29 insertions, 18 deletions
diff --git a/src/WixToolset.Core/Bind/FileResolver.cs b/src/WixToolset.Core/Bind/FileResolver.cs index 8d624e6f..2142d261 100644 --- a/src/WixToolset.Core/Bind/FileResolver.cs +++ b/src/WixToolset.Core/Bind/FileResolver.cs | |||
@@ -221,7 +221,7 @@ namespace WixToolset.Core.Bind | |||
221 | } | 221 | } |
222 | catch (ArgumentException) | 222 | catch (ArgumentException) |
223 | { | 223 | { |
224 | throw new WixException(WixErrors.IllegalCharactersInPath(path)); | 224 | throw new WixException(ErrorMessages.IllegalCharactersInPath(path)); |
225 | } | 225 | } |
226 | } | 226 | } |
227 | 227 | ||
diff --git a/src/WixToolset.Core/Bind/ResolveDelayedFieldsCommand.cs b/src/WixToolset.Core/Bind/ResolveDelayedFieldsCommand.cs index 4585b71a..3ded9a87 100644 --- a/src/WixToolset.Core/Bind/ResolveDelayedFieldsCommand.cs +++ b/src/WixToolset.Core/Bind/ResolveDelayedFieldsCommand.cs | |||
@@ -7,6 +7,7 @@ namespace WixToolset.Core.Bind | |||
7 | using System.Globalization; | 7 | using System.Globalization; |
8 | using WixToolset.Data; | 8 | using WixToolset.Data; |
9 | using WixToolset.Extensibility; | 9 | using WixToolset.Extensibility; |
10 | using WixToolset.Extensibility.Services; | ||
10 | 11 | ||
11 | /// <summary> | 12 | /// <summary> |
12 | /// Resolves the fields which had variables that needed to be resolved after the file information | 13 | /// Resolves the fields which had variables that needed to be resolved after the file information |
@@ -19,12 +20,15 @@ namespace WixToolset.Core.Bind | |||
19 | /// </summary> | 20 | /// </summary> |
20 | /// <param name="delayedFields">The fields which had resolution delayed.</param> | 21 | /// <param name="delayedFields">The fields which had resolution delayed.</param> |
21 | /// <param name="variableCache">The file information to use when resolving variables.</param> | 22 | /// <param name="variableCache">The file information to use when resolving variables.</param> |
22 | public ResolveDelayedFieldsCommand(IEnumerable<IDelayedField> delayedFields, Dictionary<string, string> variableCache) | 23 | public ResolveDelayedFieldsCommand(IMessaging messaging, IEnumerable<IDelayedField> delayedFields, Dictionary<string, string> variableCache) |
23 | { | 24 | { |
25 | this.Messaging = messaging; | ||
24 | this.DelayedFields = delayedFields; | 26 | this.DelayedFields = delayedFields; |
25 | this.VariableCache = variableCache; | 27 | this.VariableCache = variableCache; |
26 | } | 28 | } |
27 | 29 | ||
30 | private IMessaging Messaging { get; } | ||
31 | |||
28 | private IEnumerable<IDelayedField> DelayedFields { get;} | 32 | private IEnumerable<IDelayedField> DelayedFields { get;} |
29 | 33 | ||
30 | private IDictionary<string, string> VariableCache { get; } | 34 | private IDictionary<string, string> VariableCache { get; } |
@@ -58,7 +62,7 @@ namespace WixToolset.Core.Bind | |||
58 | } | 62 | } |
59 | catch (WixException we) | 63 | catch (WixException we) |
60 | { | 64 | { |
61 | Messaging.Instance.OnMessage(we.Error); | 65 | this.Messaging.Write(we.Error); |
62 | continue; | 66 | continue; |
63 | } | 67 | } |
64 | } | 68 | } |
@@ -103,7 +107,7 @@ namespace WixToolset.Core.Bind | |||
103 | } | 107 | } |
104 | catch (WixException we) | 108 | catch (WixException we) |
105 | { | 109 | { |
106 | Messaging.Instance.OnMessage(we.Error); | 110 | this.Messaging.Write(we.Error); |
107 | } | 111 | } |
108 | } | 112 | } |
109 | } | 113 | } |
diff --git a/src/WixToolset.Core/Bind/ResolveFieldsCommand.cs b/src/WixToolset.Core/Bind/ResolveFieldsCommand.cs index 9253f352..e8c90956 100644 --- a/src/WixToolset.Core/Bind/ResolveFieldsCommand.cs +++ b/src/WixToolset.Core/Bind/ResolveFieldsCommand.cs | |||
@@ -7,12 +7,15 @@ namespace WixToolset.Core.Bind | |||
7 | using WixToolset.Data; | 7 | using WixToolset.Data; |
8 | using WixToolset.Data.Bind; | 8 | using WixToolset.Data.Bind; |
9 | using WixToolset.Extensibility; | 9 | using WixToolset.Extensibility; |
10 | using WixToolset.Extensibility.Services; | ||
10 | 11 | ||
11 | /// <summary> | 12 | /// <summary> |
12 | /// Resolve source fields in the tables included in the output | 13 | /// Resolve source fields in the tables included in the output |
13 | /// </summary> | 14 | /// </summary> |
14 | internal class ResolveFieldsCommand | 15 | internal class ResolveFieldsCommand |
15 | { | 16 | { |
17 | public IMessaging Messaging { private get; set; } | ||
18 | |||
16 | public bool BuildingPatch { private get; set; } | 19 | public bool BuildingPatch { private get; set; } |
17 | 20 | ||
18 | public IBindVariableResolver BindVariableResolver { private get; set; } | 21 | public IBindVariableResolver BindVariableResolver { private get; set; } |
@@ -75,7 +78,7 @@ namespace WixToolset.Core.Bind | |||
75 | } | 78 | } |
76 | 79 | ||
77 | // Move to next row if we've hit an error resolving variables. | 80 | // Move to next row if we've hit an error resolving variables. |
78 | if (Messaging.Instance.EncounteredError) // TODO: make this error handling more specific to just the failure to resolve variables in this field. | 81 | if (this.Messaging.EncounteredError) // TODO: make this error handling more specific to just the failure to resolve variables in this field. |
79 | { | 82 | { |
80 | continue; | 83 | continue; |
81 | } | 84 | } |
@@ -151,7 +154,7 @@ namespace WixToolset.Core.Bind | |||
151 | catch (WixFileNotFoundException) | 154 | catch (WixFileNotFoundException) |
152 | { | 155 | { |
153 | // display the error with source line information | 156 | // display the error with source line information |
154 | Messaging.Instance.OnMessage(WixErrors.FileNotFound(row.SourceLineNumbers, objectField.Path)); | 157 | this.Messaging.Write(ErrorMessages.FileNotFound(row.SourceLineNumbers, objectField.Path)); |
155 | } | 158 | } |
156 | } | 159 | } |
157 | 160 | ||
@@ -208,7 +211,7 @@ namespace WixToolset.Core.Bind | |||
208 | catch (WixFileNotFoundException) | 211 | catch (WixFileNotFoundException) |
209 | { | 212 | { |
210 | // display the error with source line information | 213 | // display the error with source line information |
211 | Messaging.Instance.OnMessage(WixErrors.FileNotFound(row.SourceLineNumbers, (string)objectField.PreviousData)); | 214 | Messaging.Instance.Write(WixErrors.FileNotFound(row.SourceLineNumbers, (string)objectField.PreviousData)); |
212 | } | 215 | } |
213 | } | 216 | } |
214 | } | 217 | } |
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 | |||
9 | using WixToolset.Data; | 9 | using WixToolset.Data; |
10 | using WixToolset.Data.Bind; | 10 | using WixToolset.Data.Bind; |
11 | using WixToolset.Extensibility; | 11 | using WixToolset.Extensibility; |
12 | using WixToolset.Extensibility.Services; | ||
12 | 13 | ||
13 | internal class TransferFilesCommand | 14 | internal class TransferFilesCommand |
14 | { | 15 | { |
15 | public TransferFilesCommand(IEnumerable<BindPath> bindPaths, IEnumerable<IBinderExtension> extensions, IEnumerable<FileTransfer> fileTransfers, bool suppressAclReset) | 16 | public TransferFilesCommand(IMessaging messaging, IEnumerable<BindPath> bindPaths, IEnumerable<IBinderExtension> extensions, IEnumerable<FileTransfer> fileTransfers, bool suppressAclReset) |
16 | { | 17 | { |
17 | this.FileResolver = new FileResolver(bindPaths, extensions); | 18 | this.FileResolver = new FileResolver(bindPaths, extensions); |
19 | this.Messaging = messaging; | ||
18 | this.FileTransfers = fileTransfers; | 20 | this.FileTransfers = fileTransfers; |
19 | this.SuppressAclReset = suppressAclReset; | 21 | this.SuppressAclReset = suppressAclReset; |
20 | } | 22 | } |
21 | 23 | ||
22 | private FileResolver FileResolver { get; } | 24 | private FileResolver FileResolver { get; } |
23 | 25 | ||
26 | private IMessaging Messaging { get; } | ||
27 | |||
24 | private IEnumerable<FileTransfer> FileTransfers { get; } | 28 | private IEnumerable<FileTransfer> FileTransfers { get; } |
25 | 29 | ||
26 | private bool SuppressAclReset { get; } | 30 | private bool SuppressAclReset { get; } |
@@ -47,12 +51,12 @@ namespace WixToolset.Core.Bind | |||
47 | { | 51 | { |
48 | if (fileTransfer.Move) | 52 | if (fileTransfer.Move) |
49 | { | 53 | { |
50 | Messaging.Instance.OnMessage(WixVerboses.MoveFile(fileSource, fileTransfer.Destination)); | 54 | this.Messaging.Write(VerboseMessages.MoveFile(fileSource, fileTransfer.Destination)); |
51 | this.TransferFile(true, fileSource, fileTransfer.Destination); | 55 | this.TransferFile(true, fileSource, fileTransfer.Destination); |
52 | } | 56 | } |
53 | else | 57 | else |
54 | { | 58 | { |
55 | Messaging.Instance.OnMessage(WixVerboses.CopyFile(fileSource, fileTransfer.Destination)); | 59 | this.Messaging.Write(VerboseMessages.CopyFile(fileSource, fileTransfer.Destination)); |
56 | this.TransferFile(false, fileSource, fileTransfer.Destination); | 60 | this.TransferFile(false, fileSource, fileTransfer.Destination); |
57 | } | 61 | } |
58 | 62 | ||
@@ -61,7 +65,7 @@ namespace WixToolset.Core.Bind | |||
61 | } | 65 | } |
62 | catch (FileNotFoundException e) | 66 | catch (FileNotFoundException e) |
63 | { | 67 | { |
64 | throw new WixFileNotFoundException(e.FileName); | 68 | throw new WixFileNotFoundException(fileTransfer.SourceLineNumbers, e.FileName); |
65 | } | 69 | } |
66 | catch (DirectoryNotFoundException) | 70 | catch (DirectoryNotFoundException) |
67 | { | 71 | { |
@@ -72,7 +76,7 @@ namespace WixToolset.Core.Bind | |||
72 | } | 76 | } |
73 | 77 | ||
74 | string directory = Path.GetDirectoryName(fileTransfer.Destination); | 78 | string directory = Path.GetDirectoryName(fileTransfer.Destination); |
75 | Messaging.Instance.OnMessage(WixVerboses.CreateDirectory(directory)); | 79 | this.Messaging.Write(VerboseMessages.CreateDirectory(directory)); |
76 | Directory.CreateDirectory(directory); | 80 | Directory.CreateDirectory(directory); |
77 | retry = true; | 81 | retry = true; |
78 | } | 82 | } |
@@ -86,7 +90,7 @@ namespace WixToolset.Core.Bind | |||
86 | 90 | ||
87 | if (File.Exists(fileTransfer.Destination)) | 91 | if (File.Exists(fileTransfer.Destination)) |
88 | { | 92 | { |
89 | Messaging.Instance.OnMessage(WixVerboses.RemoveDestinationFile(fileTransfer.Destination)); | 93 | this.Messaging.Write(VerboseMessages.RemoveDestinationFile(fileTransfer.Destination)); |
90 | 94 | ||
91 | // try to ensure the file is not read-only | 95 | // try to ensure the file is not read-only |
92 | FileAttributes attributes = File.GetAttributes(fileTransfer.Destination); | 96 | FileAttributes attributes = File.GetAttributes(fileTransfer.Destination); |
@@ -96,7 +100,7 @@ namespace WixToolset.Core.Bind | |||
96 | } | 100 | } |
97 | catch (ArgumentException) // thrown for unauthorized access errors | 101 | catch (ArgumentException) // thrown for unauthorized access errors |
98 | { | 102 | { |
99 | throw new WixException(WixErrors.UnauthorizedAccess(fileTransfer.Destination)); | 103 | throw new WixException(ErrorMessages.UnauthorizedAccess(fileTransfer.Destination)); |
100 | } | 104 | } |
101 | 105 | ||
102 | // try to delete the file | 106 | // try to delete the file |
@@ -106,7 +110,7 @@ namespace WixToolset.Core.Bind | |||
106 | } | 110 | } |
107 | catch (IOException) | 111 | catch (IOException) |
108 | { | 112 | { |
109 | throw new WixException(WixErrors.FileInUse(null, fileTransfer.Destination)); | 113 | throw new WixException(ErrorMessages.FileInUse(null, fileTransfer.Destination)); |
110 | } | 114 | } |
111 | 115 | ||
112 | retry = true; | 116 | retry = true; |
@@ -126,7 +130,7 @@ namespace WixToolset.Core.Bind | |||
126 | 130 | ||
127 | if (File.Exists(fileTransfer.Destination)) | 131 | if (File.Exists(fileTransfer.Destination)) |
128 | { | 132 | { |
129 | Messaging.Instance.OnMessage(WixVerboses.RemoveDestinationFile(fileTransfer.Destination)); | 133 | this.Messaging.Write(VerboseMessages.RemoveDestinationFile(fileTransfer.Destination)); |
130 | 134 | ||
131 | // ensure the file is not read-only, then delete it | 135 | // ensure the file is not read-only, then delete it |
132 | FileAttributes attributes = File.GetAttributes(fileTransfer.Destination); | 136 | FileAttributes attributes = File.GetAttributes(fileTransfer.Destination); |
@@ -137,7 +141,7 @@ namespace WixToolset.Core.Bind | |||
137 | } | 141 | } |
138 | catch (IOException) | 142 | catch (IOException) |
139 | { | 143 | { |
140 | throw new WixException(WixErrors.FileInUse(null, fileTransfer.Destination)); | 144 | throw new WixException(ErrorMessages.FileInUse(null, fileTransfer.Destination)); |
141 | } | 145 | } |
142 | 146 | ||
143 | retry = true; | 147 | retry = true; |
@@ -168,7 +172,7 @@ namespace WixToolset.Core.Bind | |||
168 | } | 172 | } |
169 | catch | 173 | catch |
170 | { | 174 | { |
171 | Messaging.Instance.OnMessage(WixWarnings.UnableToResetAcls()); | 175 | this.Messaging.Write(WarningMessages.UnableToResetAcls()); |
172 | } | 176 | } |
173 | } | 177 | } |
174 | } | 178 | } |