diff options
| author | Rob Mensching <rob@firegiant.com> | 2019-05-24 08:47:36 -0700 |
|---|---|---|
| committer | Rob Mensching <rob@firegiant.com> | 2019-05-24 15:18:30 -0700 |
| commit | 7462108b714d07161126dcedda5312daef54ae13 (patch) | |
| tree | 5d7021acbbedafd6373fc26c609c2d4c85332075 /src/WixToolset.Data/IntermediateField.cs | |
| parent | 9d0fea2e7617e4ba4fc85fbe412c812d9bc65564 (diff) | |
| download | wix-7462108b714d07161126dcedda5312daef54ae13.tar.gz wix-7462108b714d07161126dcedda5312daef54ae13.tar.bz2 wix-7462108b714d07161126dcedda5312daef54ae13.zip | |
Add tuple.IsNull(), remove fields when set to default and other small fixes
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 | } |
