scripts
This commit is contained in:
@@ -0,0 +1,100 @@
|
||||
using System;
|
||||
|
||||
namespace System.Collections.Generic
|
||||
{
|
||||
/// <summary>Provides a base class for implementations of the <see cref="T:System.Collections.Generic.IEqualityComparer`1" /> generic interface.</summary>
|
||||
/// <typeparam name="T">The type of objects to compare.</typeparam>
|
||||
// Token: 0x02000106 RID: 262
|
||||
[Serializable]
|
||||
public abstract class EqualityComparer<T> : IEqualityComparer<T>, IEqualityComparer
|
||||
{
|
||||
// Token: 0x06000CE8 RID: 3304 RVA: 0x00039D18 File Offset: 0x00037F18
|
||||
static EqualityComparer()
|
||||
{
|
||||
if (typeof(IEquatable<T>).IsAssignableFrom(typeof(T)))
|
||||
{
|
||||
EqualityComparer<T>._default = (EqualityComparer<T>)Activator.CreateInstance(typeof(GenericEqualityComparer<>).MakeGenericType(new Type[] { typeof(T) }));
|
||||
}
|
||||
else
|
||||
{
|
||||
EqualityComparer<T>._default = new EqualityComparer<T>.DefaultComparer();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Returns a hash code for the specified object.</summary>
|
||||
/// <returns>A hash code for the specified object.</returns>
|
||||
/// <param name="obj">The <see cref="T:System.Object" /> for which a hash code is to be returned.</param>
|
||||
/// <exception cref="T:System.ArgumentNullException">The type of <paramref name="obj" /> is a reference type and <paramref name="obj" /> is null.-or-<paramref name="obj" /> is of a type that cannot be cast to type <paramref name="T" />.</exception>
|
||||
// Token: 0x06000CE9 RID: 3305 RVA: 0x00039D84 File Offset: 0x00037F84
|
||||
int IEqualityComparer.GetHashCode(object obj)
|
||||
{
|
||||
return this.GetHashCode((T)((object)obj));
|
||||
}
|
||||
|
||||
/// <summary>Determines whether the specified objects are equal.</summary>
|
||||
/// <returns>true if the specified objects are equal; otherwise, false.</returns>
|
||||
/// <param name="x">The first object to compare.</param>
|
||||
/// <param name="y">The second object to compare.</param>
|
||||
/// <exception cref="T:System.ArgumentException">
|
||||
/// <paramref name="x" /> or <paramref name="y" /> is of a type that cannot be cast to type <paramref name="T" />.</exception>
|
||||
// Token: 0x06000CEA RID: 3306 RVA: 0x00039D94 File Offset: 0x00037F94
|
||||
bool IEqualityComparer.Equals(object x, object y)
|
||||
{
|
||||
return this.Equals((T)((object)x), (T)((object)y));
|
||||
}
|
||||
|
||||
/// <summary>When overridden in a derived class, serves as a hash function for the specified object for hashing algorithms and data structures, such as a hash table.</summary>
|
||||
/// <returns>A hash code for the specified object.</returns>
|
||||
/// <param name="obj">The object for which to get a hash code.</param>
|
||||
/// <exception cref="T:System.ArgumentNullException">The type of <paramref name="obj" /> is a reference type and <paramref name="obj" /> is null.</exception>
|
||||
// Token: 0x06000CEB RID: 3307
|
||||
public abstract int GetHashCode(T obj);
|
||||
|
||||
/// <summary>When overridden in a derived class, determines whether two objects of type <paramref name="T" /> are equal.</summary>
|
||||
/// <returns>true if the specified objects are equal; otherwise, false.</returns>
|
||||
/// <param name="x">The first object to compare.</param>
|
||||
/// <param name="y">The second object to compare.</param>
|
||||
// Token: 0x06000CEC RID: 3308
|
||||
public abstract bool Equals(T x, T y);
|
||||
|
||||
/// <summary>Returns a default equality comparer for the type specified by the generic argument.</summary>
|
||||
/// <returns>The default instance of the <see cref="T:System.Collections.Generic.EqualityComparer`1" /> class for type <paramref name="T" />.</returns>
|
||||
// Token: 0x170001EE RID: 494
|
||||
// (get) Token: 0x06000CED RID: 3309 RVA: 0x00039DA8 File Offset: 0x00037FA8
|
||||
public static EqualityComparer<T> Default
|
||||
{
|
||||
get
|
||||
{
|
||||
return EqualityComparer<T>._default;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x0400037B RID: 891
|
||||
private static readonly EqualityComparer<T> _default;
|
||||
|
||||
// Token: 0x02000107 RID: 263
|
||||
[Serializable]
|
||||
private sealed class DefaultComparer : EqualityComparer<T>
|
||||
{
|
||||
// Token: 0x06000CEF RID: 3311 RVA: 0x00039DB8 File Offset: 0x00037FB8
|
||||
public override int GetHashCode(T obj)
|
||||
{
|
||||
if (obj == null)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
return obj.GetHashCode();
|
||||
}
|
||||
|
||||
// Token: 0x06000CF0 RID: 3312 RVA: 0x00039DD4 File Offset: 0x00037FD4
|
||||
public override bool Equals(T x, T y)
|
||||
{
|
||||
if (x == null)
|
||||
{
|
||||
return y == null;
|
||||
}
|
||||
return x.Equals(y);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user