diff options
author | Rob Mensching <rob@firegiant.com> | 2019-05-12 15:42:42 -0700 |
---|---|---|
committer | Rob Mensching <rob@firegiant.com> | 2019-05-12 23:11:34 -0700 |
commit | 95d2fa40d86b9aa120c27703b653a90ee89058f8 (patch) | |
tree | 2891380178be9b896ddcb4fc690e2355e055a64d | |
parent | 50ec4f8c9dd0ec91a8bc4db4295e54710059428d (diff) | |
download | wix-95d2fa40d86b9aa120c27703b653a90ee89058f8.tar.gz wix-95d2fa40d86b9aa120c27703b653a90ee89058f8.tar.bz2 wix-95d2fa40d86b9aa120c27703b653a90ee89058f8.zip |
Correctly set the underlying data types when intermediate value loaded
-rw-r--r-- | src/WixToolset.Data/IntermediateFieldValue.cs | 52 |
1 files changed, 42 insertions, 10 deletions
diff --git a/src/WixToolset.Data/IntermediateFieldValue.cs b/src/WixToolset.Data/IntermediateFieldValue.cs index 88bfb910..b09903dc 100644 --- a/src/WixToolset.Data/IntermediateFieldValue.cs +++ b/src/WixToolset.Data/IntermediateFieldValue.cs | |||
@@ -1,4 +1,4 @@ | |||
1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. | 1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. |
2 | 2 | ||
3 | namespace WixToolset.Data | 3 | namespace WixToolset.Data |
4 | { | 4 | { |
@@ -55,18 +55,45 @@ namespace WixToolset.Data | |||
55 | 55 | ||
56 | var value = data; | 56 | var value = data; |
57 | 57 | ||
58 | if (data is string) | 58 | switch (value) |
59 | { | 59 | { |
60 | } | 60 | case int intData: |
61 | else if (data is long) | 61 | switch (type) |
62 | { | ||
63 | if (type == IntermediateFieldType.Number) | ||
64 | { | 62 | { |
65 | value = Convert.ToInt32(data); | 63 | case IntermediateFieldType.Bool: |
64 | value = intData != 0; | ||
65 | break; | ||
66 | |||
67 | case IntermediateFieldType.LargeNumber: | ||
68 | value = Convert.ToInt64(data); | ||
69 | break; | ||
70 | |||
71 | case IntermediateFieldType.Path: | ||
72 | case IntermediateFieldType.String: | ||
73 | value = intData.ToString(); | ||
74 | break; | ||
66 | } | 75 | } |
67 | } | 76 | break; |
68 | else if (data is JsonObject jsonData) | 77 | |
69 | { | 78 | case long longData: |
79 | switch (type) | ||
80 | { | ||
81 | case IntermediateFieldType.Bool: | ||
82 | value = longData != 0; | ||
83 | break; | ||
84 | |||
85 | case IntermediateFieldType.Number: | ||
86 | value = Convert.ToInt32(longData); | ||
87 | break; | ||
88 | |||
89 | case IntermediateFieldType.Path: | ||
90 | case IntermediateFieldType.String: | ||
91 | value = longData.ToString(); | ||
92 | break; | ||
93 | } | ||
94 | break; | ||
95 | |||
96 | case JsonObject jsonData: | ||
70 | jsonData.TryGetValue("embeddedIndex", out var embeddedIndex); | 97 | jsonData.TryGetValue("embeddedIndex", out var embeddedIndex); |
71 | 98 | ||
72 | value = new IntermediateFieldPathValue | 99 | value = new IntermediateFieldPathValue |
@@ -75,6 +102,11 @@ namespace WixToolset.Data | |||
75 | EmbeddedFileIndex = (embeddedIndex == null) ? null : (int?)Convert.ToInt32(embeddedIndex), | 102 | EmbeddedFileIndex = (embeddedIndex == null) ? null : (int?)Convert.ToInt32(embeddedIndex), |
76 | Path = jsonData.GetValueOrDefault<string>("path"), | 103 | Path = jsonData.GetValueOrDefault<string>("path"), |
77 | }; | 104 | }; |
105 | break; | ||
106 | |||
107 | // Nothing to do for this case, so leave it out. | ||
108 | // case string stringData: | ||
109 | // break; | ||
78 | } | 110 | } |
79 | 111 | ||
80 | var previousValueJson = jsonObject.GetValueOrDefault<JsonObject>("prev"); | 112 | var previousValueJson = jsonObject.GetValueOrDefault<JsonObject>("prev"); |