// 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; /// /// Bind variable. /// public sealed class BindVariable { /// /// Gets or sets the source line number. /// public SourceLineNumber SourceLineNumbers { get; set; } /// /// Gets or sets the variable identifier. /// /// The variable identifier. public string Id { get; set; } /// /// Gets or sets the variable's value. /// /// The variable's value. public string Value { get; set; } /// /// Gets or sets whether this variable is overridable. /// /// Whether this variable is overridable. 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("name"), Value = jsonObject.GetValueOrDefault("value"), Overridable = jsonObject.GetValueOrDefault("overridable", false), SourceLineNumbers = jsonObject.GetValueOrDefault("ln") }; return variable; } } }