summaryrefslogtreecommitdiff
path: root/src/mscorlib/src/System/Collections/Comparer.cs
diff options
context:
space:
mode:
Diffstat (limited to 'src/mscorlib/src/System/Collections/Comparer.cs')
-rw-r--r--src/mscorlib/src/System/Collections/Comparer.cs64
1 files changed, 38 insertions, 26 deletions
diff --git a/src/mscorlib/src/System/Collections/Comparer.cs b/src/mscorlib/src/System/Collections/Comparer.cs
index 928b0f9..7f4f9f0 100644
--- a/src/mscorlib/src/System/Collections/Comparer.cs
+++ b/src/mscorlib/src/System/Collections/Comparer.cs
@@ -12,46 +12,53 @@
**
**
===========================================================*/
-namespace System.Collections {
-
- using System;
- using System.Globalization;
- using System.Runtime.Serialization;
- using System.Diagnostics.Contracts;
+using System;
+using System.Globalization;
+using System.Runtime.Serialization;
+using System.Diagnostics.Contracts;
+
+namespace System.Collections
+{
[Serializable]
- internal sealed class Comparer : IComparer , ISerializable
+ internal sealed class Comparer : IComparer, ISerializable
{
- private CompareInfo m_compareInfo;
+ private CompareInfo m_compareInfo;
public static readonly Comparer Default = new Comparer(CultureInfo.CurrentCulture);
public static readonly Comparer DefaultInvariant = new Comparer(CultureInfo.InvariantCulture);
-
+
private const String CompareInfoName = "CompareInfo";
- private Comparer() {
+ private Comparer()
+ {
m_compareInfo = null;
}
- public Comparer(CultureInfo culture) {
- if (culture==null) {
+ public Comparer(CultureInfo culture)
+ {
+ if (culture == null)
+ {
throw new ArgumentNullException(nameof(culture));
}
Contract.EndContractBlock();
m_compareInfo = culture.CompareInfo;
}
-
- private Comparer(SerializationInfo info, StreamingContext context) {
+
+ private Comparer(SerializationInfo info, StreamingContext context)
+ {
m_compareInfo = null;
- SerializationInfoEnumerator enumerator = info.GetEnumerator();
- while( enumerator.MoveNext()) {
- switch( enumerator.Name) {
+ SerializationInfoEnumerator enumerator = info.GetEnumerator();
+ while (enumerator.MoveNext())
+ {
+ switch (enumerator.Name)
+ {
case CompareInfoName:
- m_compareInfo = (CompareInfo) info.GetValue(CompareInfoName, typeof(CompareInfo));
+ m_compareInfo = (CompareInfo)info.GetValue(CompareInfoName, typeof(CompareInfo));
break;
}
}
}
-
+
// Compares two Objects by calling CompareTo. If a ==
// b,0 is returned. If a implements
// IComparable, a.CompareTo(b) is returned. If a
@@ -59,11 +66,13 @@ namespace System.Collections {
// -(b.CompareTo(a)) is returned, otherwise an
// exception is thrown.
//
- public int Compare(Object a, Object b) {
+ public int Compare(Object a, Object b)
+ {
if (a == b) return 0;
if (a == null) return -1;
if (b == null) return 1;
- if (m_compareInfo != null) {
+ if (m_compareInfo != null)
+ {
String sa = a as String;
String sb = b as String;
if (sa != null && sb != null)
@@ -78,18 +87,21 @@ namespace System.Collections {
if (ib != null)
return -ib.CompareTo(a);
- throw new ArgumentException(Environment.GetResourceString("Argument_ImplementIComparable"));
+ throw new ArgumentException(SR.Argument_ImplementIComparable);
}
- public void GetObjectData(SerializationInfo info, StreamingContext context) {
- if (info==null) {
+ public void GetObjectData(SerializationInfo info, StreamingContext context)
+ {
+ if (info == null)
+ {
throw new ArgumentNullException(nameof(info));
}
Contract.EndContractBlock();
- if( m_compareInfo != null) {
+ if (m_compareInfo != null)
+ {
info.AddValue(CompareInfoName, m_compareInfo);
}
- }
+ }
}
}