-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathJsonValueComparer.cs
39 lines (33 loc) · 925 Bytes
/
JsonValueComparer.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
using System.Text.Json.Nodes;
namespace System.Text.Json.JsonDiffPatch
{
/// <summary>
/// Comparer for <see cref="JsonValue"/>.
/// </summary>
public static partial class JsonValueComparer
{
/// <summary>
/// Compares two <see cref="JsonValue"/>.
/// </summary>
/// <param name="x">The left value.</param>
/// <param name="y">The right value.</param>
public static int Compare(JsonValue? x, JsonValue? y)
{
if (x is null && y is null)
{
return 0;
}
if (x is null)
{
return -1;
}
if (y is null)
{
return 1;
}
var wrapperX = new JsonValueWrapper(x);
var wrapperY = new JsonValueWrapper(y);
return wrapperX.CompareTo(ref wrapperY);
}
}
}