forked from nhibernate/nhibernate-core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathReferenceComparer.cs
40 lines (34 loc) · 865 Bytes
/
ReferenceComparer.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
39
40
using System;
using System.Collections;
using System.Collections.Generic;
namespace NHibernate.Util
{
/// <summary>
/// Compares objects by reference equality
/// </summary>
/// <typeparam name="T"></typeparam>
[Serializable]
class ReferenceComparer<T> : IEqualityComparer, IEqualityComparer<T> where T : class
{
private ReferenceComparer()
{
}
public bool Equals(T x, T y)
{
return ReferenceEquals(x, y);
}
public int GetHashCode(T obj)
{
return System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(obj);
}
bool IEqualityComparer.Equals(object x, object y)
{
return ReferenceEquals(x, y);
}
int IEqualityComparer.GetHashCode(object obj)
{
return System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(obj);
}
public static readonly ReferenceComparer<T> Instance = new ReferenceComparer<T>();
}
}