aboutsummaryrefslogtreecommitdiff
path: root/src/WixToolset.Data/Json
diff options
context:
space:
mode:
authorRob Mensching <rob@firegiant.com>2017-12-30 01:31:32 -0800
committerRob Mensching <rob@firegiant.com>2017-12-30 01:31:32 -0800
commit7b013ac66a36e0f73d480ef28771a65f64b57e19 (patch)
tree4a2996a1a539337ae27f3b9dfc692cf6052b897c /src/WixToolset.Data/Json
parentbcfae2a06a3a6c7e778b615e765b5a9efe847c0c (diff)
downloadwix-7b013ac66a36e0f73d480ef28771a65f64b57e19.tar.gz
wix-7b013ac66a36e0f73d480ef28771a65f64b57e19.tar.bz2
wix-7b013ac66a36e0f73d480ef28771a65f64b57e19.zip
Support serializing localization information in Intermediates
Diffstat (limited to 'src/WixToolset.Data/Json')
-rw-r--r--src/WixToolset.Data/Json/JsonObjectExtensions.cs45
1 files changed, 45 insertions, 0 deletions
diff --git a/src/WixToolset.Data/Json/JsonObjectExtensions.cs b/src/WixToolset.Data/Json/JsonObjectExtensions.cs
index 296a7ab6..e9e170ee 100644
--- a/src/WixToolset.Data/Json/JsonObjectExtensions.cs
+++ b/src/WixToolset.Data/Json/JsonObjectExtensions.cs
@@ -7,6 +7,51 @@ namespace WixToolset.Data
7 7
8 internal static class JsonObjectExtensions 8 internal static class JsonObjectExtensions
9 { 9 {
10 public static JsonObject AddNonDefaultValue(this JsonObject jsonObject, string key, bool value, bool defaultValue = default(bool))
11 {
12 if (value != defaultValue)
13 {
14 jsonObject.Add(key, value);
15 }
16
17 return jsonObject;
18 }
19
20 public static JsonObject AddNonDefaultValue(this JsonObject jsonObject, string key, int value, int defaultValue = default(int))
21 {
22 if (value != defaultValue)
23 {
24 jsonObject.Add(key, value);
25 }
26
27 return jsonObject;
28 }
29
30 public static JsonObject AddNonDefaultValue(this JsonObject jsonObject, string key, object value, object defaultValue = null)
31 {
32 if (value != defaultValue)
33 {
34 jsonObject.Add(key, value);
35 }
36
37 return jsonObject;
38 }
39
40 public static JsonObject AddIsNotNullOrEmpty(this JsonObject jsonObject, string key, string value)
41 {
42 if (!String.IsNullOrEmpty(value))
43 {
44 jsonObject.Add(key, value);
45 }
46
47 return jsonObject;
48 }
49
50 public static bool GetValueOrDefault(this JsonObject jsonObject, string key, bool defaultValue)
51 {
52 return jsonObject.TryGetValue(key, out var value) ? Convert.ToBoolean(value) : defaultValue;
53 }
54
10 public static int GetValueOrDefault(this JsonObject jsonObject, string key, int defaultValue) 55 public static int GetValueOrDefault(this JsonObject jsonObject, string key, int defaultValue)
11 { 56 {
12 return jsonObject.TryGetValue(key, out var value) ? Convert.ToInt32(value) : defaultValue; 57 return jsonObject.TryGetValue(key, out var value) ? Convert.ToInt32(value) : defaultValue;