[reflection] Coop handles icalls in System.Reflection and System.RuntimeTypeHandle...
[mono.git] / mcs / class / referencesource / System.Activities.Presentation / Microsoft.Tools.Common / Microsoft / Activities / Presentation / Xaml / ObjectReferenceEqualityComparer.cs
1 //----------------------------------------------------------------
2 // <copyright company="Microsoft Corporation">
3 //     Copyright (c) Microsoft Corporation.  All rights reserved.
4 // </copyright>
5 //----------------------------------------------------------------
6
7 namespace Microsoft.Activities.Presentation.Xaml
8 {
9     using System.Collections.Generic;
10     using System.Runtime.CompilerServices;
11
12     internal sealed class ObjectReferenceEqualityComparer<T> : IEqualityComparer<T> where T : class
13     {
14         private static ObjectReferenceEqualityComparer<T> defaultComparer;
15
16         private ObjectReferenceEqualityComparer()
17         {
18         }
19
20         public static ObjectReferenceEqualityComparer<T> Default
21         {
22             get
23             {
24                 if (defaultComparer == null)
25                 {
26                     defaultComparer = new ObjectReferenceEqualityComparer<T>();
27                 }
28
29                 return defaultComparer;
30             }
31         }
32
33         public bool Equals(T x, T y)
34         {
35             return object.ReferenceEquals(x, y);
36         }
37
38         public int GetHashCode(T obj)
39         {
40             return RuntimeHelpers.GetHashCode(obj);
41         }
42     }
43 }