1+ using System ;
2+
13namespace GraphQL . Common . Response {
24
35 /// <summary>
46 /// Represents the location where the <see cref="GraphQLError"/> has been found
57 /// </summary>
6- public class GraphQLLocation {
8+ public class GraphQLLocation : IEquatable < GraphQLLocation > {
79
810 /// <summary>
911 /// The Column
@@ -15,6 +17,51 @@ public class GraphQLLocation {
1517 /// </summary>
1618 public uint Line { get ; set ; }
1719
20+ /// <summary>
21+ /// Returns the hash code for this instance.
22+ /// </summary>
23+ /// <returns>The hash code</returns>
24+ public override int GetHashCode ( ) =>
25+ this . Column . GetHashCode ( ) ^ this . Line . GetHashCode ( ) ;
26+
27+ /// <summary>
28+ /// Returns a value that indicates whether this instance is equal to a specified object
29+ /// </summary>
30+ /// <param name="obj">The object to compare with this instance</param>
31+ /// <returns>true if obj is an instance of <see cref="GraphQLLocation"/> and equals the value of the instance; otherwise, false</returns>
32+ public override bool Equals ( object obj ) {
33+ if ( obj is GraphQLLocation ) {
34+ return Equals ( obj as GraphQLLocation ) ;
35+ }
36+ return false ;
37+ }
38+
39+ /// <summary>
40+ /// Returns a value that indicates whether this instance is equal to a specified object
41+ /// </summary>
42+ /// <param name="other">The object to compare with this instance</param>
43+ /// <returns>true if other is an instance of <see cref="GraphQLLocation"/> and equals the value of the instance; otherwise, false</returns>
44+ public bool Equals ( GraphQLLocation other ) =>
45+ Equals ( this . Column , other . Column ) && Equals ( this . Line , other . Line ) ;
46+
47+ /// <summary>
48+ /// Tests whether two specified <see cref="GraphQLLocation"/> instances are equivalent
49+ /// </summary>
50+ /// <param name="left">The <see cref="GraphQLLocation"/> instance that is to the left of the equality operator</param>
51+ /// <param name="right">The <see cref="GraphQLLocation"/> instance that is to the right of the equality operator</param>
52+ /// <returns>true if left and right are equal; otherwise, false</returns>
53+ public static bool operator == ( GraphQLLocation left , GraphQLLocation right ) =>
54+ left . Equals ( right ) ;
55+
56+ /// <summary>
57+ /// Tests whether two specified <see cref="GraphQLLocation"/> instances are not equal
58+ /// </summary>
59+ /// <param name="left">The <see cref="GraphQLLocation"/> instance that is to the left of the not equal operator</param>
60+ /// <param name="right">The <see cref="GraphQLLocation"/> instance that is to the right of the not equal operator</param>
61+ /// <returns>true if left and right are unequal; otherwise, false</returns>
62+ public static bool operator != ( GraphQLLocation left , GraphQLLocation right ) =>
63+ ! left . Equals ( right ) ;
64+
1865 }
1966
2067}
0 commit comments