Skip to content

Commit 271deda

Browse files
committed
JSON: make ObservableJsonValue comparable
- implement IComparable<ObservableJsonValue> and IComparable<JsonValue>
1 parent 079db3c commit 271deda

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

Doxense.Core/Serialization/JSON/Observable/ObservableJsonValue.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ namespace Doxense.Serialization.Json
1414
/// <summary>Observable JSON Object that will capture all reads</summary>
1515
[DebuggerDisplay("{ToString(),nq}")]
1616
[PublicAPI]
17-
public sealed class ObservableJsonValue : IJsonProxyNode, IJsonSerializable, IJsonPackable, IEquatable<ObservableJsonValue>, IEquatable<JsonValue>, IEnumerable<ObservableJsonValue>
17+
public sealed class ObservableJsonValue : IJsonProxyNode, IJsonSerializable, IJsonPackable, IEquatable<ObservableJsonValue>, IEquatable<JsonValue>, IComparable<ObservableJsonValue>, IComparable<JsonValue>, IEnumerable<ObservableJsonValue>
1818
{
1919

2020
public ObservableJsonValue(IObservableJsonContext? ctx, IJsonProxyNode? parent, JsonPathSegment segment, JsonValue json)
@@ -1097,8 +1097,16 @@ public IEnumerator<ObservableJsonValue> GetEnumerator()
10971097
/// <inheritdoc />
10981098
public bool Equals(JsonValue? other) => other == null ? IsNullOrMissing() : this.ToJson().StrictEquals(other);
10991099

1100+
/// <inheritdoc />
1101+
public int CompareTo(ObservableJsonValue? other) => other != null ? this.ToJson().CompareTo(other.ToJson()) : Exists() ? +1 : 0;
1102+
1103+
/// <inheritdoc />
1104+
public int CompareTo(JsonValue? other) => other != null ? this.ToJson().CompareTo(other) : Exists() ? +1 : 0;
1105+
1106+
/// <inheritdoc />
11001107
void IJsonSerializable.JsonSerialize(CrystalJsonWriter writer) => this.ToJson().JsonSerialize(writer);
11011108

1109+
/// <inheritdoc />
11021110
JsonValue IJsonPackable.JsonPack(CrystalJsonSettings settings, ICrystalJsonTypeResolver resolver) => this.ToJson();
11031111

11041112
public JsonArray AsArray() => this.ToJson().AsArray();

0 commit comments

Comments
 (0)