aboutsummaryrefslogtreecommitdiff
path: root/src/WixToolset.Data/IntermediateFieldExtensions.cs
diff options
context:
space:
mode:
Diffstat (limited to 'src/WixToolset.Data/IntermediateFieldExtensions.cs')
-rw-r--r--src/WixToolset.Data/IntermediateFieldExtensions.cs53
1 files changed, 34 insertions, 19 deletions
diff --git a/src/WixToolset.Data/IntermediateFieldExtensions.cs b/src/WixToolset.Data/IntermediateFieldExtensions.cs
index be225452..89a6b903 100644
--- a/src/WixToolset.Data/IntermediateFieldExtensions.cs
+++ b/src/WixToolset.Data/IntermediateFieldExtensions.cs
@@ -21,26 +21,15 @@ namespace WixToolset.Data
21 { 21 {
22 // Null is always allowed. 22 // Null is always allowed.
23 } 23 }
24 else if (field.Type == IntermediateFieldType.Bool && !(value is bool)) 24 else if (field.Type == IntermediateFieldType.String && !(value is string))
25 { 25 {
26 if (value is int) 26 if (value is int)
27 { 27 {
28 data = ((int)value) != 0; 28 data = value.ToString();
29 } 29 }
30 else if (value is string str) 30 else if (value is bool b)
31 { 31 {
32 if (str.Equals("yes", StringComparison.OrdinalIgnoreCase) || str.Equals("true", StringComparison.OrdinalIgnoreCase)) 32 data = b ? "true" : "false";
33 {
34 data = true;
35 }
36 else if (str.Equals("no", StringComparison.OrdinalIgnoreCase) || str.Equals("false", StringComparison.OrdinalIgnoreCase))
37 {
38 data = false;
39 }
40 else
41 {
42 throw new ArgumentException(nameof(value));
43 }
44 } 33 }
45 else 34 else
46 { 35 {
@@ -58,15 +47,26 @@ namespace WixToolset.Data
58 throw new ArgumentException(nameof(value)); 47 throw new ArgumentException(nameof(value));
59 } 48 }
60 } 49 }
61 else if (field.Type == IntermediateFieldType.String && !(value is string)) 50 else if (field.Type == IntermediateFieldType.Bool && !(value is bool))
62 { 51 {
63 if (value is int) 52 if (value is int)
64 { 53 {
65 data = value.ToString(); 54 data = ((int)value) != 0;
66 } 55 }
67 else if (value is bool b) 56 else if (value is string str)
68 { 57 {
69 data = b ? "true" : "false"; 58 if (str.Equals("yes", StringComparison.OrdinalIgnoreCase) || str.Equals("true", StringComparison.OrdinalIgnoreCase))
59 {
60 data = true;
61 }
62 else if (str.Equals("no", StringComparison.OrdinalIgnoreCase) || str.Equals("false", StringComparison.OrdinalIgnoreCase))
63 {
64 data = false;
65 }
66 else
67 {
68 throw new ArgumentException(nameof(value));
69 }
70 } 70 }
71 else 71 else
72 { 72 {
@@ -84,6 +84,21 @@ namespace WixToolset.Data
84 throw new ArgumentException(nameof(value)); 84 throw new ArgumentException(nameof(value));
85 } 85 }
86 } 86 }
87 else if (field.Type == IntermediateFieldType.LargeNumber && !(value is long))
88 {
89 if (value is string str && Int64.TryParse(str, out var number))
90 {
91 data = number;
92 }
93 else if (value is int i)
94 {
95 data = (long)i;
96 }
97 else
98 {
99 throw new ArgumentException(nameof(value));
100 }
101 }
87 102
88 field.Value = new IntermediateFieldValue 103 field.Value = new IntermediateFieldValue
89 { 104 {