using System; using System.Globalization; using System.Runtime.InteropServices; using System.Runtime.Serialization; namespace System.Collections { /// Compares two objects for equivalence, where string comparisons are case-sensitive. /// 2 // Token: 0x02000127 RID: 295 [ComVisible(true)] [Serializable] public sealed class Comparer : ISerializable, IComparer { // Token: 0x06000F51 RID: 3921 RVA: 0x00040574 File Offset: 0x0003E774 private Comparer() { } /// Initializes a new instance of the class using the specified . /// The to use for the new . /// /// is null. // Token: 0x06000F52 RID: 3922 RVA: 0x0004057C File Offset: 0x0003E77C public Comparer(CultureInfo culture) { if (culture == null) { throw new ArgumentNullException("culture"); } this.m_compareInfo = culture.CompareInfo; } /// Performs a case-sensitive comparison of two objects of the same type and returns a value indicating whether one is less than, equal to, or greater than the other. /// Value Condition Less than zero is less than . Zero equals . Greater than zero is greater than . /// The first object to compare. /// The second object to compare. /// Neither nor implements the interface.-or- and are of different types and neither one can handle comparisons with the other. /// 2 // Token: 0x06000F54 RID: 3924 RVA: 0x000405C0 File Offset: 0x0003E7C0 public int Compare(object a, object b) { if (a == b) { return 0; } if (a == null) { return -1; } if (b == null) { return 1; } if (this.m_compareInfo != null) { string text = a as string; string text2 = b as string; if (text != null && text2 != null) { return this.m_compareInfo.Compare(text, text2); } } if (a is IComparable) { return (a as IComparable).CompareTo(b); } if (b is IComparable) { return -(b as IComparable).CompareTo(a); } throw new ArgumentException(Locale.GetText("Neither 'a' nor 'b' implements IComparable.")); } /// Populates a object with the data required for serialization. /// The object to populate with data. /// The context information about the source or destination of the serialization. /// The parameter is null. /// 2 // Token: 0x06000F55 RID: 3925 RVA: 0x0004065C File Offset: 0x0003E85C public void GetObjectData(SerializationInfo info, StreamingContext context) { if (info == null) { throw new ArgumentNullException("info"); } info.AddValue("CompareInfo", this.m_compareInfo, typeof(CompareInfo)); } /// Represents an instance of that is associated with the of the current thread. This field is read-only. /// 1 // Token: 0x040003B9 RID: 953 public static readonly Comparer Default = new Comparer(); /// Represents an instance of that is associated with . This field is read-only. /// 1 // Token: 0x040003BA RID: 954 public static readonly Comparer DefaultInvariant = new Comparer(CultureInfo.InvariantCulture); // Token: 0x040003BB RID: 955 private CompareInfo m_compareInfo; } }