Skip to content

Commit

Permalink
Fixes HasData check (rakijah#35)
Browse files Browse the repository at this point in the history
The constructor already checks whether the object is empty. Since the information is read-only, set `HasData` from there.
  • Loading branch information
VulcanShot committed Dec 27, 2023
1 parent 57d6084 commit 48c89d6
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions CSGSI/Nodes/NodeBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public class NodeBase
/// <summary>
/// The data that was passed via JSON.
/// </summary>
protected JObject _data;
protected readonly JObject _data;

/// <summary>
/// The raw JSON string that was used to construct this node.
Expand All @@ -22,7 +22,7 @@ public class NodeBase
/// <summary>
/// Whether or not this node contains data (i.e. JSON string is not empty)
/// </summary>
public bool HasData => !string.IsNullOrWhiteSpace(JSON);
public bool HasData { get; private set; }

internal NodeBase(string json)
{
Expand All @@ -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;
Expand Down

0 comments on commit 48c89d6

Please sign in to comment.