aboutsummaryrefslogtreecommitdiff
path: root/src/WixToolset.Data/Json/JsonObjectExtensions.cs
diff options
context:
space:
mode:
authorRob Mensching <rob@firegiant.com>2021-03-01 23:13:11 -0800
committerRob Mensching <rob@firegiant.com>2021-03-02 01:54:57 -0800
commita96d1a916bfcf35f77d48f70215d62b298bfb933 (patch)
tree00c1625058424783a3ef4726c0d7b11bd46baba3 /src/WixToolset.Data/Json/JsonObjectExtensions.cs
parent26415c014397c463f2954e0bd9ff742110c5ea75 (diff)
downloadwix-a96d1a916bfcf35f77d48f70215d62b298bfb933.tar.gz
wix-a96d1a916bfcf35f77d48f70215d62b298bfb933.tar.bz2
wix-a96d1a916bfcf35f77d48f70215d62b298bfb933.zip
Small cleanup
Diffstat (limited to 'src/WixToolset.Data/Json/JsonObjectExtensions.cs')
-rw-r--r--src/WixToolset.Data/Json/JsonObjectExtensions.cs6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/WixToolset.Data/Json/JsonObjectExtensions.cs b/src/WixToolset.Data/Json/JsonObjectExtensions.cs
index e9e170ee..bc52333c 100644
--- a/src/WixToolset.Data/Json/JsonObjectExtensions.cs
+++ b/src/WixToolset.Data/Json/JsonObjectExtensions.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
3namespace WixToolset.Data 3namespace WixToolset.Data
4{ 4{
@@ -64,13 +64,13 @@ namespace WixToolset.Data
64 64
65 public static T GetValueOrDefault<T>(this JsonObject jsonObject, string key, T defaultValue = default(T)) where T : class 65 public static T GetValueOrDefault<T>(this JsonObject jsonObject, string key, T defaultValue = default(T)) where T : class
66 { 66 {
67 return jsonObject.TryGetValue(key, out var value) ? value as T: defaultValue; 67 return jsonObject.TryGetValue(key, out var value) ? value as T : defaultValue;
68 } 68 }
69 69
70 public static T GetEnumOrDefault<T>(this JsonObject jsonObject, string key, T defaultValue) where T : struct 70 public static T GetEnumOrDefault<T>(this JsonObject jsonObject, string key, T defaultValue) where T : struct
71 { 71 {
72#if DEBUG 72#if DEBUG
73 if (!typeof(T).IsEnum) throw new ArgumentException("This method is designed to only only support enums.", nameof(T)); 73 if (!typeof(T).IsEnum) { throw new ArgumentException("This method only supports enums.", nameof(T)); }
74#endif 74#endif
75 var value = jsonObject.GetValueOrDefault<string>(key); 75 var value = jsonObject.GetValueOrDefault<string>(key);
76 return Enum.TryParse(value, true, out T e) ? e : defaultValue; 76 return Enum.TryParse(value, true, out T e) ? e : defaultValue;