diff options
| author | Sean Hall <r.sean.hall@gmail.com> | 2020-04-10 10:17:26 +1000 |
|---|---|---|
| committer | Sean Hall <r.sean.hall@gmail.com> | 2020-04-10 10:21:39 +1000 |
| commit | f92c72546326fb9b893bb7760691ee67ec7ab832 (patch) | |
| tree | 405b3305fc4c08d25003cd601b3284bede89fa1a /src/wixext/HttpCompiler.cs | |
| parent | cff40371860cded7924b0010a26c9e8dc779cb0f (diff) | |
| download | wix-f92c72546326fb9b893bb7760691ee67ec7ab832.tar.gz wix-f92c72546326fb9b893bb7760691ee67ec7ab832.tar.bz2 wix-f92c72546326fb9b893bb7760691ee67ec7ab832.zip | |
Modernize HttpCompiler and tuples.
Diffstat (limited to 'src/wixext/HttpCompiler.cs')
| -rw-r--r-- | src/wixext/HttpCompiler.cs | 57 |
1 files changed, 30 insertions, 27 deletions
diff --git a/src/wixext/HttpCompiler.cs b/src/wixext/HttpCompiler.cs index 094f5594..e47990db 100644 --- a/src/wixext/HttpCompiler.cs +++ b/src/wixext/HttpCompiler.cs | |||
| @@ -28,9 +28,9 @@ namespace WixToolset.Http | |||
| 28 | switch (parentElement.Name.LocalName) | 28 | switch (parentElement.Name.LocalName) |
| 29 | { | 29 | { |
| 30 | case "ServiceInstall": | 30 | case "ServiceInstall": |
| 31 | string serviceInstallName = context["ServiceInstallName"]; | 31 | var serviceInstallName = context["ServiceInstallName"]; |
| 32 | string serviceUser = String.IsNullOrEmpty(serviceInstallName) ? null : String.Concat("NT SERVICE\\", serviceInstallName); | 32 | var serviceUser = String.IsNullOrEmpty(serviceInstallName) ? null : String.Concat("NT SERVICE\\", serviceInstallName); |
| 33 | string serviceComponentId = context["ServiceInstallComponentId"]; | 33 | var serviceComponentId = context["ServiceInstallComponentId"]; |
| 34 | 34 | ||
| 35 | switch (element.Name.LocalName) | 35 | switch (element.Name.LocalName) |
| 36 | { | 36 | { |
| @@ -69,15 +69,14 @@ namespace WixToolset.Http | |||
| 69 | /// <param name="securityPrincipal">The security principal of the parent element (null if nested under Component).</param> | 69 | /// <param name="securityPrincipal">The security principal of the parent element (null if nested under Component).</param> |
| 70 | private void ParseUrlReservationElement(Intermediate intermediate, IntermediateSection section, XElement node, string componentId, string securityPrincipal) | 70 | private void ParseUrlReservationElement(Intermediate intermediate, IntermediateSection section, XElement node, string componentId, string securityPrincipal) |
| 71 | { | 71 | { |
| 72 | SourceLineNumber sourceLineNumbers = this.ParseHelper.GetSourceLineNumbers(node); | 72 | var sourceLineNumbers = this.ParseHelper.GetSourceLineNumbers(node); |
| 73 | Identifier id = null; | 73 | Identifier id = null; |
| 74 | int handleExisting = HttpConstants.heReplace; | 74 | var handleExisting = HttpConstants.heReplace; |
| 75 | string handleExistingValue = null; | ||
| 76 | string sddl = null; | 75 | string sddl = null; |
| 77 | string url = null; | 76 | string url = null; |
| 78 | bool foundACE = false; | 77 | var foundACE = false; |
| 79 | 78 | ||
| 80 | foreach (XAttribute attrib in node.Attributes()) | 79 | foreach (var attrib in node.Attributes()) |
| 81 | { | 80 | { |
| 82 | if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || this.Namespace == attrib.Name.Namespace) | 81 | if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || this.Namespace == attrib.Name.Namespace) |
| 83 | { | 82 | { |
| @@ -87,7 +86,7 @@ namespace WixToolset.Http | |||
| 87 | id = this.ParseHelper.GetAttributeIdentifier(sourceLineNumbers, attrib); | 86 | id = this.ParseHelper.GetAttributeIdentifier(sourceLineNumbers, attrib); |
| 88 | break; | 87 | break; |
| 89 | case "HandleExisting": | 88 | case "HandleExisting": |
| 90 | handleExistingValue = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); | 89 | var handleExistingValue = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); |
| 91 | switch (handleExistingValue) | 90 | switch (handleExistingValue) |
| 92 | { | 91 | { |
| 93 | case "replace": | 92 | case "replace": |
| @@ -128,7 +127,7 @@ namespace WixToolset.Http | |||
| 128 | } | 127 | } |
| 129 | 128 | ||
| 130 | // Parse UrlAce children. | 129 | // Parse UrlAce children. |
| 131 | foreach (XElement child in node.Elements()) | 130 | foreach (var child in node.Elements()) |
| 132 | { | 131 | { |
| 133 | if (this.Namespace == child.Name.Namespace) | 132 | if (this.Namespace == child.Name.Namespace) |
| 134 | { | 133 | { |
| @@ -170,23 +169,25 @@ namespace WixToolset.Http | |||
| 170 | 169 | ||
| 171 | if (!this.Messaging.EncounteredError) | 170 | if (!this.Messaging.EncounteredError) |
| 172 | { | 171 | { |
| 173 | var row = (WixHttpUrlReservationTuple)this.ParseHelper.CreateRow(section, sourceLineNumbers, "WixHttpUrlReservation", id); | 172 | section.AddTuple(new WixHttpUrlReservationTuple(sourceLineNumbers, id) |
| 174 | row.HandleExisting = handleExisting; | 173 | { |
| 175 | row.Sddl = sddl; | 174 | HandleExisting = handleExisting, |
| 176 | row.Url = url; | 175 | Sddl = sddl, |
| 177 | row.Component_ = componentId; | 176 | Url = url, |
| 177 | ComponentRef = componentId, | ||
| 178 | }); | ||
| 178 | 179 | ||
| 179 | if (this.Context.Platform == Platform.ARM) | 180 | if (this.Context.Platform == Platform.ARM) |
| 180 | { | 181 | { |
| 181 | // Ensure ARM version of the CA is referenced. | 182 | // Ensure ARM version of the CA is referenced. |
| 182 | this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, "CustomAction", "WixSchedHttpUrlReservationsInstall_ARM"); | 183 | this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, TupleDefinitions.CustomAction, "WixSchedHttpUrlReservationsInstall_ARM"); |
| 183 | this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, "CustomAction", "WixSchedHttpUrlReservationsUninstall_ARM"); | 184 | this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, TupleDefinitions.CustomAction, "WixSchedHttpUrlReservationsUninstall_ARM"); |
| 184 | } | 185 | } |
| 185 | else | 186 | else |
| 186 | { | 187 | { |
| 187 | // All other supported platforms use x86. | 188 | // All other supported platforms use x86. |
| 188 | this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, "CustomAction", "WixSchedHttpUrlReservationsInstall"); | 189 | this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, TupleDefinitions.CustomAction, "WixSchedHttpUrlReservationsInstall"); |
| 189 | this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, "CustomAction", "WixSchedHttpUrlReservationsUninstall"); | 190 | this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, TupleDefinitions.CustomAction, "WixSchedHttpUrlReservationsUninstall"); |
| 190 | } | 191 | } |
| 191 | } | 192 | } |
| 192 | } | 193 | } |
| @@ -199,13 +200,13 @@ namespace WixToolset.Http | |||
| 199 | /// <param name="defaultSecurityPrincipal">The default security principal.</param> | 200 | /// <param name="defaultSecurityPrincipal">The default security principal.</param> |
| 200 | private void ParseUrlAceElement(Intermediate intermediate, IntermediateSection section, XElement node, string urlReservationId, string defaultSecurityPrincipal) | 201 | private void ParseUrlAceElement(Intermediate intermediate, IntermediateSection section, XElement node, string urlReservationId, string defaultSecurityPrincipal) |
| 201 | { | 202 | { |
| 202 | SourceLineNumber sourceLineNumbers = this.ParseHelper.GetSourceLineNumbers(node); | 203 | var sourceLineNumbers = this.ParseHelper.GetSourceLineNumbers(node); |
| 203 | Identifier id = null; | 204 | Identifier id = null; |
| 204 | string securityPrincipal = defaultSecurityPrincipal; | 205 | var securityPrincipal = defaultSecurityPrincipal; |
| 205 | int rights = HttpConstants.GENERIC_ALL; | 206 | var rights = HttpConstants.GENERIC_ALL; |
| 206 | string rightsValue = null; | 207 | string rightsValue = null; |
| 207 | 208 | ||
| 208 | foreach (XAttribute attrib in node.Attributes()) | 209 | foreach (var attrib in node.Attributes()) |
| 209 | { | 210 | { |
| 210 | if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || this.Namespace == attrib.Name.Namespace) | 211 | if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || this.Namespace == attrib.Name.Namespace) |
| 211 | { | 212 | { |
| @@ -262,10 +263,12 @@ namespace WixToolset.Http | |||
| 262 | 263 | ||
| 263 | if (!this.Messaging.EncounteredError) | 264 | if (!this.Messaging.EncounteredError) |
| 264 | { | 265 | { |
| 265 | var row = (WixHttpUrlAceTuple)this.ParseHelper.CreateRow(section, sourceLineNumbers, "WixHttpUrlAce", id); | 266 | section.AddTuple(new WixHttpUrlAceTuple(sourceLineNumbers, id) |
| 266 | row.WixHttpUrlReservation_ = urlReservationId; | 267 | { |
| 267 | row.SecurityPrincipal = securityPrincipal; | 268 | WixHttpUrlReservationRef = urlReservationId, |
| 268 | row.Rights = rights; | 269 | SecurityPrincipal = securityPrincipal, |
| 270 | Rights = rights, | ||
| 271 | }); | ||
| 269 | } | 272 | } |
| 270 | } | 273 | } |
| 271 | } | 274 | } |
