blob: 2310f447bd1db595ef7a7a2d3e974f1f4b2f8b94 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
// 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.
namespace WixToolset.Data
{
using System;
using System.Diagnostics;
using SimpleJson;
[DebuggerDisplay("Name={Name,nq} Type={Type} Value={Value?.AsString()}")]
public class IntermediateField
{
public IntermediateField(IntermediateFieldDefinition definition) => this.Definition = definition;
public IntermediateFieldDefinition Definition { get; }
public string Name => this.Definition.Name;
public IntermediateFieldType Type => this.Definition.Type;
public string Context => this.Value?.Context;
public IntermediateFieldValue PreviousValue => this.Value?.PreviousValue;
internal IntermediateFieldValue Value { get; set; }
public static explicit operator bool(IntermediateField field) => field.AsBool();
public static explicit operator bool? (IntermediateField field) => field.AsNullableBool();
public static explicit operator long(IntermediateField field) => field.AsLargeNumber();
public static explicit operator long?(IntermediateField field) => field.AsNullableLargeNumber();
public static explicit operator int(IntermediateField field) => field.AsNumber();
public static explicit operator int? (IntermediateField field) => field.AsNullableNumber();
public static explicit operator string(IntermediateField field) => field.AsString();
internal static IntermediateField Deserialize(IntermediateFieldDefinition definition, Uri baseUri, JsonObject jsonObject)
{
IntermediateField field = null;
if (jsonObject != null)
{
field = new IntermediateField(definition);
field.Value = IntermediateFieldValue.Deserialize(jsonObject, baseUri, definition.Type);
}
return field;
}
internal JsonObject Serialize() => this.Value?.Serialize();
}
}
|