-
Notifications
You must be signed in to change notification settings - Fork 168
Expand file tree
/
Copy pathMemberComparer.cs
More file actions
35 lines (30 loc) · 907 Bytes
/
Copy pathMemberComparer.cs
File metadata and controls
35 lines (30 loc) · 907 Bytes
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
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license.
using System.Collections.Generic;
using System.Reflection;
namespace Microsoft.ClearScript.Util
{
internal sealed class MemberComparer<T> : EqualityComparer<T> where T : MemberInfo
{
public static readonly MemberComparer<T> Instance = new MemberComparer<T>();
private MemberComparer()
{
}
public override bool Equals(T x, T y)
{
try
{
return (x.Module == y.Module) && (x.MetadataToken == y.MetadataToken);
}
catch
{
return x == y;
}
}
public override int GetHashCode(T obj)
{
// ReSharper disable once ConditionIsAlwaysTrueOrFalse
return (obj == null) ? 0 : obj.GetHashCode();
}
}
}