diff options
Diffstat (limited to 'src/wixext/MsmqCompiler.cs')
| -rw-r--r-- | src/wixext/MsmqCompiler.cs | 98 |
1 files changed, 52 insertions, 46 deletions
diff --git a/src/wixext/MsmqCompiler.cs b/src/wixext/MsmqCompiler.cs index 5365f0fb..15c3f3ca 100644 --- a/src/wixext/MsmqCompiler.cs +++ b/src/wixext/MsmqCompiler.cs | |||
| @@ -7,6 +7,7 @@ namespace WixToolset.Msmq | |||
| 7 | using System.Xml.Linq; | 7 | using System.Xml.Linq; |
| 8 | using WixToolset.Data; | 8 | using WixToolset.Data; |
| 9 | using WixToolset.Extensibility; | 9 | using WixToolset.Extensibility; |
| 10 | using WixToolset.Msmq.Tuples; | ||
| 10 | 11 | ||
| 11 | /// <summary> | 12 | /// <summary> |
| 12 | /// The compiler for the WiX Toolset MSMQ Extension. | 13 | /// The compiler for the WiX Toolset MSMQ Extension. |
| @@ -69,8 +70,8 @@ namespace WixToolset.Msmq | |||
| 69 | switch (parentElement.Name.LocalName) | 70 | switch (parentElement.Name.LocalName) |
| 70 | { | 71 | { |
| 71 | case "Component": | 72 | case "Component": |
| 72 | string componentId = context["ComponentId"]; | 73 | var componentId = context["ComponentId"]; |
| 73 | string directoryId = context["DirectoryId"]; | 74 | var directoryId = context["DirectoryId"]; |
| 74 | 75 | ||
| 75 | switch (element.Name.LocalName) | 76 | switch (element.Name.LocalName) |
| 76 | { | 77 | { |
| @@ -98,20 +99,20 @@ namespace WixToolset.Msmq | |||
| 98 | /// <param name="componentKey">Identifier of parent component.</param> | 99 | /// <param name="componentKey">Identifier of parent component.</param> |
| 99 | private void ParseMessageQueueElement(Intermediate intermediate, IntermediateSection section, XElement node, string componentId) | 100 | private void ParseMessageQueueElement(Intermediate intermediate, IntermediateSection section, XElement node, string componentId) |
| 100 | { | 101 | { |
| 101 | SourceLineNumber sourceLineNumbers = this.ParseHelper.GetSourceLineNumbers(node); | 102 | var sourceLineNumbers = this.ParseHelper.GetSourceLineNumbers(node); |
| 102 | 103 | ||
| 103 | Identifier id = null; | 104 | Identifier id = null; |
| 104 | int basePriority = CompilerConstants.IntegerNotSet; | 105 | var basePriority = CompilerConstants.IntegerNotSet; |
| 105 | int journalQuota = CompilerConstants.IntegerNotSet; | 106 | var journalQuota = CompilerConstants.IntegerNotSet; |
| 106 | string label = null; | 107 | string label = null; |
| 107 | string multicastAddress = null; | 108 | string multicastAddress = null; |
| 108 | string pathName = null; | 109 | string pathName = null; |
| 109 | int privLevel = CompilerConstants.IntegerNotSet; | 110 | var privLevel = CompilerConstants.IntegerNotSet; |
| 110 | int quota = CompilerConstants.IntegerNotSet; | 111 | var quota = CompilerConstants.IntegerNotSet; |
| 111 | string serviceTypeGuid = null; | 112 | string serviceTypeGuid = null; |
| 112 | int attributes = 0; | 113 | int attributes = 0; |
| 113 | 114 | ||
| 114 | foreach (XAttribute attrib in node.Attributes()) | 115 | foreach (var attrib in node.Attributes()) |
| 115 | { | 116 | { |
| 116 | if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || this.Namespace == attrib.Name.Namespace) | 117 | if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || this.Namespace == attrib.Name.Namespace) |
| 117 | { | 118 | { |
| @@ -156,7 +157,7 @@ namespace WixToolset.Msmq | |||
| 156 | pathName = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); | 157 | pathName = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); |
| 157 | break; | 158 | break; |
| 158 | case "PrivLevel": | 159 | case "PrivLevel": |
| 159 | string privLevelAttr = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); | 160 | var privLevelAttr = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); |
| 160 | switch (privLevelAttr) | 161 | switch (privLevelAttr) |
| 161 | { | 162 | { |
| 162 | case "none": | 163 | case "none": |
| @@ -200,7 +201,7 @@ namespace WixToolset.Msmq | |||
| 200 | } | 201 | } |
| 201 | } | 202 | } |
| 202 | 203 | ||
| 203 | foreach (XElement child in node.Elements()) | 204 | foreach (var child in node.Elements()) |
| 204 | { | 205 | { |
| 205 | if (this.Namespace == child.Name.Namespace) | 206 | if (this.Namespace == child.Name.Namespace) |
| 206 | { | 207 | { |
| @@ -220,32 +221,36 @@ namespace WixToolset.Msmq | |||
| 220 | } | 221 | } |
| 221 | } | 222 | } |
| 222 | 223 | ||
| 223 | var row = this.ParseHelper.CreateRow(section, sourceLineNumbers, "MessageQueue", id); | 224 | var tuple = section.AddTuple(new MessageQueueTuple(sourceLineNumbers, id) |
| 224 | row.Set(1, componentId); | 225 | { |
| 226 | ComponentRef = componentId, | ||
| 227 | Label = label, | ||
| 228 | MulticastAddress = multicastAddress, | ||
| 229 | PathName = pathName, | ||
| 230 | ServiceTypeGuid = serviceTypeGuid, | ||
| 231 | Attributes = attributes, | ||
| 232 | }); | ||
| 233 | |||
| 225 | if (CompilerConstants.IntegerNotSet != basePriority) | 234 | if (CompilerConstants.IntegerNotSet != basePriority) |
| 226 | { | 235 | { |
| 227 | row.Set(2, basePriority); | 236 | tuple.BasePriority = basePriority; |
| 228 | } | 237 | } |
| 229 | if (CompilerConstants.IntegerNotSet != journalQuota) | 238 | if (CompilerConstants.IntegerNotSet != journalQuota) |
| 230 | { | 239 | { |
| 231 | row.Set(3, journalQuota); | 240 | tuple.JournalQuota = journalQuota; |
| 232 | } | 241 | } |
| 233 | row.Set(4, label); | 242 | |
| 234 | row.Set(5, multicastAddress); | ||
| 235 | row.Set(6, pathName); | ||
| 236 | if (CompilerConstants.IntegerNotSet != privLevel) | 243 | if (CompilerConstants.IntegerNotSet != privLevel) |
| 237 | { | 244 | { |
| 238 | row.Set(7, privLevel); | 245 | tuple.PrivLevel = privLevel; |
| 239 | } | 246 | } |
| 240 | if (CompilerConstants.IntegerNotSet != quota) | 247 | if (CompilerConstants.IntegerNotSet != quota) |
| 241 | { | 248 | { |
| 242 | row.Set(8, quota); | 249 | tuple.Quota = quota; |
| 243 | } | 250 | } |
| 244 | row.Set(9, serviceTypeGuid); | ||
| 245 | row.Set(10, attributes); | ||
| 246 | 251 | ||
| 247 | this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, "CustomAction", "MessageQueuingInstall"); | 252 | this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, TupleDefinitions.CustomAction, "MessageQueuingInstall"); |
| 248 | this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, "CustomAction", "MessageQueuingUninstall"); | 253 | this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, TupleDefinitions.CustomAction, "MessageQueuingUninstall"); |
| 249 | } | 254 | } |
| 250 | 255 | ||
| 251 | /// <summary> | 256 | /// <summary> |
| @@ -256,14 +261,14 @@ namespace WixToolset.Msmq | |||
| 256 | /// <param name="applicationKey">Optional identifier of parent message queue.</param> | 261 | /// <param name="applicationKey">Optional identifier of parent message queue.</param> |
| 257 | private void ParseMessageQueuePermissionElement(Intermediate intermediate, IntermediateSection section, XElement node, string componentId, string messageQueueId) | 262 | private void ParseMessageQueuePermissionElement(Intermediate intermediate, IntermediateSection section, XElement node, string componentId, string messageQueueId) |
| 258 | { | 263 | { |
| 259 | SourceLineNumber sourceLineNumbers = this.ParseHelper.GetSourceLineNumbers(node); | 264 | var sourceLineNumbers = this.ParseHelper.GetSourceLineNumbers(node); |
| 260 | 265 | ||
| 261 | Identifier id = null; | 266 | Identifier id = null; |
| 262 | string user = null; | 267 | string user = null; |
| 263 | string group = null; | 268 | string group = null; |
| 264 | int permissions = 0; | 269 | int permissions = 0; |
| 265 | 270 | ||
| 266 | foreach (XAttribute attrib in node.Attributes()) | 271 | foreach (var attrib in node.Attributes()) |
| 267 | { | 272 | { |
| 268 | if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || this.Namespace == attrib.Name.Namespace) | 273 | if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || this.Namespace == attrib.Name.Namespace) |
| 269 | { | 274 | { |
| @@ -278,7 +283,7 @@ namespace WixToolset.Msmq | |||
| 278 | this.Messaging.Write(ErrorMessages.IllegalAttributeWhenNested(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName, node.Parent.Name.LocalName)); | 283 | this.Messaging.Write(ErrorMessages.IllegalAttributeWhenNested(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName, node.Parent.Name.LocalName)); |
| 279 | } | 284 | } |
| 280 | messageQueueId = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); | 285 | messageQueueId = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); |
| 281 | this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, "MessageQueue", messageQueueId); | 286 | this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, MsmqTupleDefinitions.MessageQueue, messageQueueId); |
| 282 | break; | 287 | break; |
| 283 | case "User": | 288 | case "User": |
| 284 | if (null != group) | 289 | if (null != group) |
| @@ -467,6 +472,11 @@ namespace WixToolset.Msmq | |||
| 467 | } | 472 | } |
| 468 | } | 473 | } |
| 469 | 474 | ||
| 475 | if (null == id) | ||
| 476 | { | ||
| 477 | id = this.ParseHelper.CreateIdentifier("mqp", componentId, messageQueueId, user, group); | ||
| 478 | } | ||
| 479 | |||
| 470 | if (null == messageQueueId) | 480 | if (null == messageQueueId) |
| 471 | { | 481 | { |
| 472 | this.Messaging.Write(ErrorMessages.ExpectedAttribute(sourceLineNumbers, node.Name.LocalName, "MessageQueue")); | 482 | this.Messaging.Write(ErrorMessages.ExpectedAttribute(sourceLineNumbers, node.Name.LocalName, "MessageQueue")); |
| @@ -480,19 +490,23 @@ namespace WixToolset.Msmq | |||
| 480 | 490 | ||
| 481 | if (null != user) | 491 | if (null != user) |
| 482 | { | 492 | { |
| 483 | var row = this.ParseHelper.CreateRow(section, sourceLineNumbers, "MessageQueueUserPermission", id); | 493 | section.AddTuple(new MessageQueueUserPermissionTuple(sourceLineNumbers, id) |
| 484 | row.Set(1, componentId); | 494 | { |
| 485 | row.Set(2, messageQueueId); | 495 | ComponentRef = componentId, |
| 486 | row.Set(3, user); | 496 | MessageQueueRef = messageQueueId, |
| 487 | row.Set(4, permissions); | 497 | UserRef = user, |
| 498 | Permissions = permissions, | ||
| 499 | }); | ||
| 488 | } | 500 | } |
| 489 | if (null != group) | 501 | if (null != group) |
| 490 | { | 502 | { |
| 491 | var row = this.ParseHelper.CreateRow(section, sourceLineNumbers, "MessageQueueGroupPermission", id); | 503 | section.AddTuple(new MessageQueueGroupPermissionTuple(sourceLineNumbers, id) |
| 492 | row.Set(1, componentId); | 504 | { |
| 493 | row.Set(2, messageQueueId); | 505 | ComponentRef = componentId, |
| 494 | row.Set(3, group); | 506 | MessageQueueRef = messageQueueId, |
| 495 | row.Set(4, permissions); | 507 | GroupRef = group, |
| 508 | Permissions = permissions, | ||
| 509 | }); | ||
| 496 | } | 510 | } |
| 497 | } | 511 | } |
| 498 | 512 | ||
| @@ -504,19 +518,11 @@ namespace WixToolset.Msmq | |||
| 504 | /// <returns></returns> | 518 | /// <returns></returns> |
| 505 | string TryFormatGuidValue(string val) | 519 | string TryFormatGuidValue(string val) |
| 506 | { | 520 | { |
| 507 | try | 521 | if (!Guid.TryParse(val, out var guid)) |
| 508 | { | ||
| 509 | Guid guid = new Guid(val); | ||
| 510 | return guid.ToString("B").ToUpper(); | ||
| 511 | } | ||
| 512 | catch (FormatException) | ||
| 513 | { | ||
| 514 | return val; | ||
| 515 | } | ||
| 516 | catch (OverflowException) | ||
| 517 | { | 522 | { |
| 518 | return val; | 523 | return val; |
| 519 | } | 524 | } |
| 525 | return guid.ToString("B").ToUpper(); | ||
| 520 | } | 526 | } |
| 521 | } | 527 | } |
| 522 | } | 528 | } |
