Merge pull request #2419 from esdrubal/xmlsubclassel
[mono.git] / mcs / class / corlib / Mono.Globalization.Unicode / SortKey.cs
index f6b86f774aa518508391efeb94b4a1518ac6f495..19c70b207ed79776e21df303c41c75d86aae5fad 100644 (file)
@@ -1,5 +1,5 @@
 //
-// Sortkey.cs
+// System.Globalization.SortKey.cs
 //
 // Author:
 //     Atsushi Enomoto  <atsushi@ximian.com>
 using System;
 using System.IO;
 using System.Globalization;
+using System.Runtime.InteropServices;
 
 namespace System.Globalization
 {
+       [System.Runtime.InteropServices.ComVisible (true)]
        [Serializable]
+       [StructLayout (LayoutKind.Sequential)]
        public class SortKey
        {
                #region Static members
-               public static int Compare (SortKey sk1, SortKey sk2)
+               public static int Compare (SortKey sortkey1, SortKey sortkey2)
                {
-                       if (Object.ReferenceEquals (sk1, sk2)
-                               || Object.ReferenceEquals (sk1.OriginalString,
-                               sk2.OriginalString))
+                       if (sortkey1 == null)
+                               throw new ArgumentNullException ("sortkey1");
+                       if (sortkey2 == null)
+                               throw new ArgumentNullException ("sortkey2");
+
+                       if (Object.ReferenceEquals (sortkey1, sortkey2)
+                               || Object.ReferenceEquals (sortkey1.OriginalString,
+                               sortkey2.OriginalString))
                                return 0;
 
-                       byte [] d1 = sk1.KeyData;
-                       byte [] d2 = sk2.KeyData;
+                       byte [] d1 = sortkey1.KeyData;
+                       byte [] d2 = sortkey2.KeyData;
 
                        int len = d1.Length > d2.Length ? d2.Length : d1.Length;
                        for (int i = 0; i < len; i++)
@@ -59,8 +67,8 @@ namespace System.Globalization
                #endregion
 
                readonly string source;
-               readonly CompareOptions options;
                readonly byte [] key;
+               readonly CompareOptions options;
                readonly int lcid;
 
                // for legacy unmanaged one
@@ -95,15 +103,15 @@ namespace System.Globalization
                public override bool Equals (object value)
                {
                        SortKey other = (value as SortKey);
-                       if(other!=null) {
-                               if((this.lcid==other.lcid) &&
-                                  (this.options==other.options) &&
-                                  (Compare (this, other)==0)) {
-                                       return(true);
+                       if (other != null) {
+                               if ((this.lcid == other.lcid) &&
+                                  (this.options == other.options) &&
+                                  (Compare (this, other) == 0)) {
+                                       return true;
                                }
                        }
 
-                       return(false);
+                       return false;
                }
 
                public override int GetHashCode ()
@@ -119,7 +127,7 @@ namespace System.Globalization
                // copy from original SortKey.cs
                public override string ToString()
                {
-                       return("SortKey - "+lcid+", "+options+", "+source);
+                       return "SortKey - " + lcid + ", " + options + ", " + source;
                }
        }
 }