aboutsummaryrefslogtreecommitdiff
path: root/src/WixToolset.Core.WindowsInstaller/ValidatorExtension.cs
diff options
context:
space:
mode:
authorRob Mensching <rob@firegiant.com>2017-12-19 12:25:40 -0800
committerRob Mensching <rob@firegiant.com>2017-12-19 12:25:40 -0800
commit155a6e96346e0cb3d9ab6f5372fa29b46ebaee89 (patch)
tree59d1f151bfde8068b6014b05b5c8cfea3402c974 /src/WixToolset.Core.WindowsInstaller/ValidatorExtension.cs
parent6f1665ed759b31bd095f186f9239232c653597cd (diff)
downloadwix-155a6e96346e0cb3d9ab6f5372fa29b46ebaee89.tar.gz
wix-155a6e96346e0cb3d9ab6f5372fa29b46ebaee89.tar.bz2
wix-155a6e96346e0cb3d9ab6f5372fa29b46ebaee89.zip
Integrate simplified message handling
Diffstat (limited to 'src/WixToolset.Core.WindowsInstaller/ValidatorExtension.cs')
-rw-r--r--src/WixToolset.Core.WindowsInstaller/ValidatorExtension.cs36
1 files changed, 12 insertions, 24 deletions
diff --git a/src/WixToolset.Core.WindowsInstaller/ValidatorExtension.cs b/src/WixToolset.Core.WindowsInstaller/ValidatorExtension.cs
index 67f5962c..48f73bf2 100644
--- a/src/WixToolset.Core.WindowsInstaller/ValidatorExtension.cs
+++ b/src/WixToolset.Core.WindowsInstaller/ValidatorExtension.cs
@@ -6,23 +6,26 @@ namespace WixToolset.Extensibility
6 using System.Collections; 6 using System.Collections;
7 using WixToolset.Data; 7 using WixToolset.Data;
8 using WixToolset.Data.WindowsInstaller; 8 using WixToolset.Data.WindowsInstaller;
9 using WixToolset.Extensibility.Services;
9 10
10 /// <summary> 11 /// <summary>
11 /// Base class for creating a validator extension. This default implementation 12 /// Base class for creating a validator extension. This default implementation
12 /// will fire and event with the ICE name and description. 13 /// will fire and event with the ICE name and description.
13 /// </summary> 14 /// </summary>
14 public class ValidatorExtension : IMessageHandler 15 public class ValidatorExtension
15 { 16 {
16 private string databaseFile; 17 private string databaseFile;
17 private Hashtable indexedSourceLineNumbers; 18 private Hashtable indexedSourceLineNumbers;
18 private Output output; 19 private Output output;
19 private SourceLineNumber sourceLineNumbers; 20 private SourceLineNumber sourceLineNumbers;
21 private readonly IMessaging messaging;
20 22
21 /// <summary> 23 /// <summary>
22 /// Instantiate a new <see cref="ValidatorExtension"/>. 24 /// Instantiate a new <see cref="ValidatorExtension"/>.
23 /// </summary> 25 /// </summary>
24 public ValidatorExtension() 26 public ValidatorExtension(IMessaging messaging)
25 { 27 {
28 this.messaging = messaging;
26 } 29 }
27 30
28 /// <summary> 31 /// <summary>
@@ -183,11 +186,11 @@ namespace WixToolset.Extensibility
183 { 186 {
184 if (null == action) 187 if (null == action)
185 { 188 {
186 throw new WixException(WixErrors.UnexpectedExternalUIMessage(message)); 189 throw new WixException(ErrorMessages.UnexpectedExternalUIMessage(message));
187 } 190 }
188 else 191 else
189 { 192 {
190 throw new WixException(WixErrors.UnexpectedExternalUIMessage(message, action)); 193 throw new WixException(ErrorMessages.UnexpectedExternalUIMessage(message, action));
191 } 194 }
192 } 195 }
193 196
@@ -209,16 +212,16 @@ namespace WixToolset.Extensibility
209 { 212 {
210 case "0": 213 case "0":
211 case "1": 214 case "1":
212 this.OnMessage(WixErrors.ValidationError(messageSourceLineNumbers, messageParts[0], messageParts[2])); 215 this.messaging.Write(ErrorMessages.ValidationError(messageSourceLineNumbers, messageParts[0], messageParts[2]));
213 break; 216 break;
214 case "2": 217 case "2":
215 this.OnMessage(WixWarnings.ValidationWarning(messageSourceLineNumbers, messageParts[0], messageParts[2])); 218 this.messaging.Write(WarningMessages.ValidationWarning(messageSourceLineNumbers, messageParts[0], messageParts[2]));
216 break; 219 break;
217 case "3": 220 case "3":
218 this.OnMessage(WixVerboses.ValidationInfo(messageParts[0], messageParts[2])); 221 this.messaging.Write(VerboseMessages.ValidationInfo(messageParts[0], messageParts[2]));
219 break; 222 break;
220 default: 223 default:
221 throw new WixException(WixErrors.InvalidValidatorMessageType(messageParts[1])); 224 throw new WixException(ErrorMessages.InvalidValidatorMessageType(messageParts[1]));
222 } 225 }
223 } 226 }
224 227
@@ -264,7 +267,7 @@ namespace WixToolset.Extensibility
264 267
265 if (this.indexedSourceLineNumbers.ContainsKey(key)) 268 if (this.indexedSourceLineNumbers.ContainsKey(key))
266 { 269 {
267 this.OnMessage(WixWarnings.DuplicatePrimaryKey(row.SourceLineNumbers, primaryKey, table.Name)); 270 this.messaging.Write(WarningMessages.DuplicatePrimaryKey(row.SourceLineNumbers, primaryKey, table.Name));
268 } 271 }
269 else 272 else
270 { 273 {
@@ -281,20 +284,5 @@ namespace WixToolset.Extensibility
281 // use the file name as the source line information 284 // use the file name as the source line information
282 return this.sourceLineNumbers; 285 return this.sourceLineNumbers;
283 } 286 }
284
285 /// <summary>
286 /// Sends a message to the <see cref="Message"/> delegate if there is one.
287 /// </summary>
288 /// <param name="e">Message event arguments.</param>
289 /// <remarks>
290 /// <para><b>Notes to Inheritors:</b> When overriding <b>OnMessage</b>
291 /// in a derived class, be sure to call the base class's
292 /// <b>OnMessage</b> method so that registered delegates recieve
293 /// the event.</para>
294 /// </remarks>
295 public virtual void OnMessage(MessageEventArgs e)
296 {
297 Messaging.Instance.OnMessage(e);
298 }
299 } 287 }
300} 288}