X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=blobdiff_plain;f=mcs%2Fclass%2Fcorlib%2FMono.Globalization.Unicode%2FSortKey.cs;h=19c70b207ed79776e21df303c41c75d86aae5fad;hb=2002994d0c06860d22253edbb7bae0ddcda7df44;hp=bbd9ef3c2ce3a5c5baba4f2fce892ceb1a195f25;hpb=26deba148e442bae2315f212fe1e1908c45a335b;p=mono.git diff --git a/mcs/class/corlib/Mono.Globalization.Unicode/SortKey.cs b/mcs/class/corlib/Mono.Globalization.Unicode/SortKey.cs index bbd9ef3c2ce..19c70b207ed 100644 --- a/mcs/class/corlib/Mono.Globalization.Unicode/SortKey.cs +++ b/mcs/class/corlib/Mono.Globalization.Unicode/SortKey.cs @@ -1,5 +1,5 @@ // -// Sortkey.cs +// System.Globalization.SortKey.cs // // Author: // Atsushi Enomoto @@ -33,22 +33,30 @@ 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 @@ -83,11 +91,11 @@ namespace System.Globalization this.options = opt; } - public string OriginalString { + public virtual string OriginalString { get { return source; } } - public byte [] KeyData { + public virtual byte [] KeyData { get { return key; } } @@ -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; } } }