diff options
Diffstat (limited to 'src/WixToolset.Data/IntermediateField.cs')
-rw-r--r-- | src/WixToolset.Data/IntermediateField.cs | 41 |
1 files changed, 11 insertions, 30 deletions
diff --git a/src/WixToolset.Data/IntermediateField.cs b/src/WixToolset.Data/IntermediateField.cs index 9aed3d81..5b511d02 100644 --- a/src/WixToolset.Data/IntermediateField.cs +++ b/src/WixToolset.Data/IntermediateField.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 | { |
@@ -9,10 +9,7 @@ namespace WixToolset.Data | |||
9 | [DebuggerDisplay("Name={Name,nq} Type={Type} Value={Value?.AsString()}")] | 9 | [DebuggerDisplay("Name={Name,nq} Type={Type} Value={Value?.AsString()}")] |
10 | public class IntermediateField | 10 | public class IntermediateField |
11 | { | 11 | { |
12 | public IntermediateField(IntermediateFieldDefinition definition) | 12 | public IntermediateField(IntermediateFieldDefinition definition) => this.Definition = definition; |
13 | { | ||
14 | this.Definition = definition; | ||
15 | } | ||
16 | 13 | ||
17 | public IntermediateFieldDefinition Definition { get; } | 14 | public IntermediateFieldDefinition Definition { get; } |
18 | 15 | ||
@@ -26,46 +23,30 @@ namespace WixToolset.Data | |||
26 | 23 | ||
27 | internal IntermediateFieldValue Value { get; set; } | 24 | internal IntermediateFieldValue Value { get; set; } |
28 | 25 | ||
29 | public static explicit operator bool(IntermediateField field) | 26 | public static explicit operator bool(IntermediateField field) => field.AsBool(); |
30 | { | ||
31 | return field.AsBool(); | ||
32 | } | ||
33 | 27 | ||
34 | public static explicit operator bool? (IntermediateField field) | 28 | public static explicit operator bool? (IntermediateField field) => field.AsNullableBool(); |
35 | { | ||
36 | return field.AsNullableBool(); | ||
37 | } | ||
38 | 29 | ||
39 | public static explicit operator int(IntermediateField field) | 30 | public static explicit operator int(IntermediateField field) => field.AsNumber(); |
40 | { | ||
41 | return field.AsNumber(); | ||
42 | } | ||
43 | 31 | ||
44 | public static explicit operator int? (IntermediateField field) | 32 | public static explicit operator int? (IntermediateField field) => field.AsNullableNumber(); |
45 | { | ||
46 | return field.AsNullableNumber(); | ||
47 | } | ||
48 | 33 | ||
49 | public static explicit operator string(IntermediateField field) | 34 | public static explicit operator string(IntermediateField field) => field.AsString(); |
50 | { | ||
51 | return field.AsString(); | ||
52 | } | ||
53 | 35 | ||
54 | internal static IntermediateField Deserialize(IntermediateFieldDefinition definition, Uri baseUri, JsonObject jsonObject) | 36 | internal static IntermediateField Deserialize(IntermediateFieldDefinition definition, Uri baseUri, JsonObject jsonObject) |
55 | { | 37 | { |
56 | var field = new IntermediateField(definition); | 38 | IntermediateField field = null; |
57 | 39 | ||
58 | if (jsonObject != null) | 40 | if (jsonObject != null) |
59 | { | 41 | { |
42 | field = new IntermediateField(definition); | ||
43 | |||
60 | field.Value = IntermediateFieldValue.Deserialize(jsonObject, baseUri, definition.Type); | 44 | field.Value = IntermediateFieldValue.Deserialize(jsonObject, baseUri, definition.Type); |
61 | } | 45 | } |
62 | 46 | ||
63 | return field; | 47 | return field; |
64 | } | 48 | } |
65 | 49 | ||
66 | internal JsonObject Serialize() | 50 | internal JsonObject Serialize() => this.Value?.Serialize(); |
67 | { | ||
68 | return this.Value?.Serialize(); | ||
69 | } | ||
70 | } | 51 | } |
71 | } | 52 | } |