using System; using System.Globalization; using System.Runtime.InteropServices; namespace System.Collections { /// Supplies a hash code for an object, using a hashing algorithm that ignores the case of strings. /// 2 // Token: 0x02000124 RID: 292 [ComVisible(true)] [Obsolete("Please use StringComparer instead.")] [Serializable] public class CaseInsensitiveHashCodeProvider : IHashCodeProvider { /// Initializes a new instance of the class using the of the current thread. // 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; } } /// Initializes a new instance of the class using the specified . /// The to use for the new . /// /// is null. // 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; } } /// Gets an instance of that is associated with the of the current thread and that is always available. /// An instance of that is associated with the of the current thread. /// 1 /// /// /// // 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; } /// Gets an instance of that is associated with and that is always available. /// An instance of that is associated with . /// 1 /// /// /// // Token: 0x17000259 RID: 601 // (get) Token: 0x06000F2E RID: 3886 RVA: 0x000400C8 File Offset: 0x0003E2C8 public static CaseInsensitiveHashCodeProvider DefaultInvariant { get { return CaseInsensitiveHashCodeProvider.singletonInvariant; } } /// Returns a hash code for the given object, using a hashing algorithm that ignores the case of strings. /// A hash code for the given object, using a hashing algorithm that ignores the case of strings. /// The for which a hash code is to be returned. /// /// is null. /// 2 /// /// /// // 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; } }