Code Coverage Statistics for Source File
Newtonsoft.Json\Linq\JTokenEqualityComparer.cs
Symbol Coverage: 83.33% (5 of 6)
Branch Coverage: 100.00% (4 of 4)
Cyclomatic Complexity Avg: 1.33 Max:2
Code Lines: 6
Symbol Coverage Trend
View:
L | V | Source |
---|---|---|
1 |
using System; |
|
2 |
using System.Collections.Generic; |
|
3 |
using System.Linq; |
|
4 |
using System.Text; |
|
5 |
||
6 |
namespace Newtonsoft.Json.Linq |
|
7 |
{ |
|
8 |
/// <summary> |
|
9 |
/// Compares tokens to determine whether they are equal. |
|
10 |
/// </summary> |
|
11 |
public class JTokenEqualityComparer : IEqualityComparer<JToken> |
|
12 |
{ |
|
13 |
/// <summary> |
|
14 |
/// Determines whether the specified objects are equal. |
|
15 |
/// </summary> |
|
16 |
/// <param name="x">The first object of type <paramref name="T"/> to compare.</param> |
|
17 |
/// <param name="y">The second object of type <paramref name="T"/> to compare.</param> |
|
18 |
/// <returns> |
|
19 |
/// true if the specified objects are equal; otherwise, false. |
|
20 |
/// </returns> |
|
21 |
public bool Equals(JToken x, JToken y) |
|
22 |
{ |
|
23 |
44 |
return JToken.DeepEquals(x, y);
|
24 |
44 |
}
|
25 |
||
26 |
/// <summary> |
|
27 |
/// Returns a hash code for the specified object. |
|
28 |
/// </summary> |
|
29 |
/// <param name="obj">The <see cref="T:System.Object"/> for which a hash code is to be returned.</param> |
|
30 |
/// <returns>A hash code for the specified object.</returns> |
|
31 |
/// <exception cref="T:System.ArgumentNullException">The type of <paramref name="obj"/> is a reference type and <paramref name="obj"/> is null.</exception> |
|
32 |
public int GetHashCode(JToken obj) |
|
33 |
{ |
|
34 |
21 |
if (obj == null)
|
35 |
0 |
return 0;
|
36 |
||
37 |
21 |
return obj.GetDeepHashCode();
|
38 |
21 |
}
|
39 |
} |
|
40 |
} |