blob: 276dae381f08f2ece7d1720a5deff09c2c9d0a59 (
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
57
58
59
60
61
62
|
// 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.Bind
{
using SimpleJson;
/// <summary>
/// Bind variable.
/// </summary>
public sealed class BindVariable
{
/// <summary>
/// Gets or sets the source line number.
/// </summary>
public SourceLineNumber SourceLineNumbers { get; set; }
/// <summary>
/// Gets or sets the variable identifier.
/// </summary>
/// <value>The variable identifier.</value>
public string Id { get; set; }
/// <summary>
/// Gets or sets the variable's value.
/// </summary>
/// <value>The variable's value.</value>
public string Value { get; set; }
/// <summary>
/// Gets or sets whether this variable is overridable.
/// </summary>
/// <value>Whether this variable is overridable.</value>
public bool Overridable { get; set; }
internal JsonObject Serialize()
{
var jsonObject = new JsonObject
{
{ "name", this.Id },
};
jsonObject.AddIsNotNullOrEmpty("value", this.Value);
jsonObject.AddNonDefaultValue("overridable", this.Overridable, false);
jsonObject.AddNonDefaultValue("ln", this.SourceLineNumbers?.Serialize());
return jsonObject;
}
internal static BindVariable Deserialize(JsonObject jsonObject)
{
var variable = new BindVariable()
{
Id = jsonObject.GetValueOrDefault<string>("name"),
Value = jsonObject.GetValueOrDefault<string>("value"),
Overridable = jsonObject.GetValueOrDefault("overridable", false),
SourceLineNumbers = jsonObject.GetValueOrDefault<SourceLineNumber>("ln")
};
return variable;
}
}
}
|