From 7b013ac66a36e0f73d480ef28771a65f64b57e19 Mon Sep 17 00:00:00 2001 From: Rob Mensching Date: Sat, 30 Dec 2017 01:31:32 -0800 Subject: Support serializing localization information in Intermediates --- src/WixToolset.Data/LocalizedControl.cs | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) (limited to 'src/WixToolset.Data/LocalizedControl.cs') diff --git a/src/WixToolset.Data/LocalizedControl.cs b/src/WixToolset.Data/LocalizedControl.cs index 979f9fde..cb60b7ba 100644 --- a/src/WixToolset.Data/LocalizedControl.cs +++ b/src/WixToolset.Data/LocalizedControl.cs @@ -3,6 +3,7 @@ namespace WixToolset.Data { using System; + using SimpleJson; public class LocalizedControl { @@ -47,5 +48,37 @@ namespace WixToolset.Data /// The id of the control. /// The localized control id. public static string GetKey(string dialog, string control) => String.Concat(dialog, "/", control); + + internal JsonObject Serialize() + { + var jsonObject = new JsonObject + { + { "dialog", this.Dialog }, + }; + + jsonObject.AddIsNotNullOrEmpty("control", this.Control); + jsonObject.AddNonDefaultValue("x", this.X, 0); + jsonObject.AddNonDefaultValue("y", this.Y, 0); + jsonObject.AddNonDefaultValue("width", this.Width, 0); + jsonObject.AddNonDefaultValue("height", this.Height, 0); + jsonObject.AddNonDefaultValue("attribs", this.Attributes, 0); + jsonObject.AddIsNotNullOrEmpty("text", this.Text); + + return jsonObject; + } + + internal static LocalizedControl Deserialize(JsonObject jsonObject) + { + var dialog = jsonObject.GetValueOrDefault("dialog"); + var control = jsonObject.GetValueOrDefault("control"); + var x = jsonObject.GetValueOrDefault("x", 0); + var y = jsonObject.GetValueOrDefault("y", 0); + var width = jsonObject.GetValueOrDefault("width", 0); + var height = jsonObject.GetValueOrDefault("height", 0); + var attribs = jsonObject.GetValueOrDefault("attribs", 0); + var text = jsonObject.GetValueOrDefault("text"); + + return new LocalizedControl(dialog, control, x, y, width, height, attribs, text); + } } } -- cgit v1.2.3-55-g6feb