aboutsummaryrefslogtreecommitdiff
path: root/src/WixToolset.Data/Json/JsonObjectExtensions.cs
diff options
context:
space:
mode:
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;