From 48c89d6c09227bd7b39368d98278fb49a84f0c8d Mon Sep 17 00:00:00 2001 From: VulcanShot Date: Wed, 27 Dec 2023 18:26:06 -0500 Subject: [PATCH] Fixes `HasData` check (#35) The constructor already checks whether the object is empty. Since the information is read-only, set `HasData` from there. --- CSGSI/Nodes/NodeBase.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/CSGSI/Nodes/NodeBase.cs b/CSGSI/Nodes/NodeBase.cs index 3d2b495..cc271d9 100644 --- a/CSGSI/Nodes/NodeBase.cs +++ b/CSGSI/Nodes/NodeBase.cs @@ -12,7 +12,7 @@ public class NodeBase /// /// The data that was passed via JSON. /// - protected JObject _data; + protected readonly JObject _data; /// /// The raw JSON string that was used to construct this node. @@ -22,7 +22,7 @@ public class NodeBase /// /// Whether or not this node contains data (i.e. JSON string is not empty) /// - public bool HasData => !string.IsNullOrWhiteSpace(JSON); + public bool HasData { get; private set; } internal NodeBase(string json) { @@ -31,6 +31,7 @@ internal NodeBase(string json) if (json.Equals("") || json.Equals("true", StringComparison.InvariantCultureIgnoreCase)) { json = "{}"; + HasData = false; } _data = JObject.Parse(json); JSON = json;