scripts
This commit is contained in:
@@ -0,0 +1,160 @@
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace System.Collections
|
||||
{
|
||||
/// <summary>Supplies a hash code for an object, using a hashing algorithm that ignores the case of strings.</summary>
|
||||
/// <filterpriority>2</filterpriority>
|
||||
// Token: 0x02000124 RID: 292
|
||||
[ComVisible(true)]
|
||||
[Obsolete("Please use StringComparer instead.")]
|
||||
[Serializable]
|
||||
public class CaseInsensitiveHashCodeProvider : IHashCodeProvider
|
||||
{
|
||||
/// <summary>Initializes a new instance of the <see cref="T:System.Collections.CaseInsensitiveHashCodeProvider" /> class using the <see cref="P:System.Threading.Thread.CurrentCulture" /> of the current thread.</summary>
|
||||
// Token: 0x06000F28 RID: 3880 RVA: 0x0003FF54 File Offset: 0x0003E154
|
||||
public CaseInsensitiveHashCodeProvider()
|
||||
{
|
||||
CultureInfo currentCulture = CultureInfo.CurrentCulture;
|
||||
if (!CaseInsensitiveHashCodeProvider.AreEqual(currentCulture, CultureInfo.InvariantCulture))
|
||||
{
|
||||
this.m_text = CultureInfo.CurrentCulture.TextInfo;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Initializes a new instance of the <see cref="T:System.Collections.CaseInsensitiveHashCodeProvider" /> class using the specified <see cref="T:System.Globalization.CultureInfo" />.</summary>
|
||||
/// <param name="culture">The <see cref="T:System.Globalization.CultureInfo" /> to use for the new <see cref="T:System.Collections.CaseInsensitiveHashCodeProvider" />. </param>
|
||||
/// <exception cref="T:System.ArgumentNullException">
|
||||
/// <paramref name="culture" /> is null. </exception>
|
||||
// Token: 0x06000F29 RID: 3881 RVA: 0x0003FF90 File Offset: 0x0003E190
|
||||
public CaseInsensitiveHashCodeProvider(CultureInfo culture)
|
||||
{
|
||||
if (culture == null)
|
||||
{
|
||||
throw new ArgumentNullException("culture");
|
||||
}
|
||||
if (!CaseInsensitiveHashCodeProvider.AreEqual(culture, CultureInfo.InvariantCulture))
|
||||
{
|
||||
this.m_text = culture.TextInfo;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Gets an instance of <see cref="T:System.Collections.CaseInsensitiveHashCodeProvider" /> that is associated with the <see cref="P:System.Threading.Thread.CurrentCulture" /> of the current thread and that is always available.</summary>
|
||||
/// <returns>An instance of <see cref="T:System.Collections.CaseInsensitiveHashCodeProvider" /> that is associated with the <see cref="P:System.Threading.Thread.CurrentCulture" /> of the current thread.</returns>
|
||||
/// <filterpriority>1</filterpriority>
|
||||
/// <PermissionSet>
|
||||
/// <IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="UnmanagedCode" />
|
||||
/// </PermissionSet>
|
||||
// Token: 0x17000258 RID: 600
|
||||
// (get) Token: 0x06000F2B RID: 3883 RVA: 0x0003FFE4 File Offset: 0x0003E1E4
|
||||
public static CaseInsensitiveHashCodeProvider Default
|
||||
{
|
||||
get
|
||||
{
|
||||
object obj = CaseInsensitiveHashCodeProvider.sync;
|
||||
CaseInsensitiveHashCodeProvider caseInsensitiveHashCodeProvider;
|
||||
lock (obj)
|
||||
{
|
||||
if (CaseInsensitiveHashCodeProvider.singleton == null)
|
||||
{
|
||||
CaseInsensitiveHashCodeProvider.singleton = new CaseInsensitiveHashCodeProvider();
|
||||
}
|
||||
else if (CaseInsensitiveHashCodeProvider.singleton.m_text == null)
|
||||
{
|
||||
if (!CaseInsensitiveHashCodeProvider.AreEqual(CultureInfo.CurrentCulture, CultureInfo.InvariantCulture))
|
||||
{
|
||||
CaseInsensitiveHashCodeProvider.singleton = new CaseInsensitiveHashCodeProvider();
|
||||
}
|
||||
}
|
||||
else if (!CaseInsensitiveHashCodeProvider.AreEqual(CaseInsensitiveHashCodeProvider.singleton.m_text, CultureInfo.CurrentCulture))
|
||||
{
|
||||
CaseInsensitiveHashCodeProvider.singleton = new CaseInsensitiveHashCodeProvider();
|
||||
}
|
||||
caseInsensitiveHashCodeProvider = CaseInsensitiveHashCodeProvider.singleton;
|
||||
}
|
||||
return caseInsensitiveHashCodeProvider;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x06000F2C RID: 3884 RVA: 0x000400A0 File Offset: 0x0003E2A0
|
||||
private static bool AreEqual(CultureInfo a, CultureInfo b)
|
||||
{
|
||||
return a.Name == b.Name;
|
||||
}
|
||||
|
||||
// Token: 0x06000F2D RID: 3885 RVA: 0x000400B4 File Offset: 0x0003E2B4
|
||||
private static bool AreEqual(TextInfo info, CultureInfo culture)
|
||||
{
|
||||
return info.CultureName == culture.Name;
|
||||
}
|
||||
|
||||
/// <summary>Gets an instance of <see cref="T:System.Collections.CaseInsensitiveHashCodeProvider" /> that is associated with <see cref="P:System.Globalization.CultureInfo.InvariantCulture" /> and that is always available.</summary>
|
||||
/// <returns>An instance of <see cref="T:System.Collections.CaseInsensitiveHashCodeProvider" /> that is associated with <see cref="P:System.Globalization.CultureInfo.InvariantCulture" />.</returns>
|
||||
/// <filterpriority>1</filterpriority>
|
||||
/// <PermissionSet>
|
||||
/// <IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="UnmanagedCode" />
|
||||
/// </PermissionSet>
|
||||
// Token: 0x17000259 RID: 601
|
||||
// (get) Token: 0x06000F2E RID: 3886 RVA: 0x000400C8 File Offset: 0x0003E2C8
|
||||
public static CaseInsensitiveHashCodeProvider DefaultInvariant
|
||||
{
|
||||
get
|
||||
{
|
||||
return CaseInsensitiveHashCodeProvider.singletonInvariant;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Returns a hash code for the given object, using a hashing algorithm that ignores the case of strings.</summary>
|
||||
/// <returns>A hash code for the given object, using a hashing algorithm that ignores the case of strings.</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">
|
||||
/// <paramref name="obj" /> is null. </exception>
|
||||
/// <filterpriority>2</filterpriority>
|
||||
/// <PermissionSet>
|
||||
/// <IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="UnmanagedCode" />
|
||||
/// </PermissionSet>
|
||||
// Token: 0x06000F2F RID: 3887 RVA: 0x000400D0 File Offset: 0x0003E2D0
|
||||
public int GetHashCode(object obj)
|
||||
{
|
||||
if (obj == null)
|
||||
{
|
||||
throw new ArgumentNullException("obj");
|
||||
}
|
||||
string text = obj as string;
|
||||
if (text == null)
|
||||
{
|
||||
return obj.GetHashCode();
|
||||
}
|
||||
int num = 0;
|
||||
if (this.m_text != null && !CaseInsensitiveHashCodeProvider.AreEqual(this.m_text, CultureInfo.InvariantCulture))
|
||||
{
|
||||
foreach (char c in this.m_text.ToLower(text))
|
||||
{
|
||||
num = num * 31 + (int)c;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int j = 0; j < text.Length; j++)
|
||||
{
|
||||
char c = char.ToLower(text[j], CultureInfo.InvariantCulture);
|
||||
num = num * 31 + (int)c;
|
||||
}
|
||||
}
|
||||
return num;
|
||||
}
|
||||
|
||||
// Token: 0x040003B3 RID: 947
|
||||
private static readonly CaseInsensitiveHashCodeProvider singletonInvariant = new CaseInsensitiveHashCodeProvider(CultureInfo.InvariantCulture);
|
||||
|
||||
// Token: 0x040003B4 RID: 948
|
||||
private static CaseInsensitiveHashCodeProvider singleton;
|
||||
|
||||
// Token: 0x040003B5 RID: 949
|
||||
private static readonly object sync = new object();
|
||||
|
||||
// Token: 0x040003B6 RID: 950
|
||||
private TextInfo m_text;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user