diff options
Diffstat (limited to 'src/WixToolset.Data/SourceLineNumber.cs')
-rw-r--r-- | src/WixToolset.Data/SourceLineNumber.cs | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/src/WixToolset.Data/SourceLineNumber.cs b/src/WixToolset.Data/SourceLineNumber.cs index 87a36132..742f6e9d 100644 --- a/src/WixToolset.Data/SourceLineNumber.cs +++ b/src/WixToolset.Data/SourceLineNumber.cs | |||
@@ -7,6 +7,7 @@ namespace WixToolset.Data | |||
7 | using System.Text; | 7 | using System.Text; |
8 | using System.Xml; | 8 | using System.Xml; |
9 | using System.Xml.Linq; | 9 | using System.Xml.Linq; |
10 | using SimpleJson; | ||
10 | 11 | ||
11 | /// <summary> | 12 | /// <summary> |
12 | /// Represents file name and line number for source file | 13 | /// Represents file name and line number for source file |
@@ -62,6 +63,38 @@ namespace WixToolset.Data | |||
62 | } | 63 | } |
63 | } | 64 | } |
64 | 65 | ||
66 | internal static SourceLineNumber Deserialize(JsonObject jsonObject) | ||
67 | { | ||
68 | var fileName = jsonObject.GetValueOrDefault<string>("file"); | ||
69 | var lineNumber = jsonObject.GetValueOrDefault("line", null); | ||
70 | |||
71 | var parentJson = jsonObject.GetValueOrDefault<JsonObject>("parent"); | ||
72 | var parent = (parentJson == null) ? null : SourceLineNumber.Deserialize(parentJson); | ||
73 | |||
74 | return new SourceLineNumber(fileName) | ||
75 | { | ||
76 | LineNumber = lineNumber, | ||
77 | Parent = parent | ||
78 | }; | ||
79 | } | ||
80 | |||
81 | internal JsonObject Serialize() | ||
82 | { | ||
83 | var jsonObject = new JsonObject | ||
84 | { | ||
85 | { "file", this.FileName }, | ||
86 | { "line", this.LineNumber } | ||
87 | }; | ||
88 | |||
89 | if (this.Parent != null) | ||
90 | { | ||
91 | var parentJson = this.Parent.Serialize(); | ||
92 | jsonObject.Add("parent", parentJson); | ||
93 | } | ||
94 | |||
95 | return jsonObject; | ||
96 | } | ||
97 | |||
65 | /// <summary> | 98 | /// <summary> |
66 | /// Creates a source line number from an encoded string. | 99 | /// Creates a source line number from an encoded string. |
67 | /// </summary> | 100 | /// </summary> |