3 using System.Globalization;
5 namespace System.Globalization
10 public static int Compare (SortKey sk1, SortKey sk2)
12 if (Object.ReferenceEquals (sk1, sk2)
13 || Object.ReferenceEquals (sk1.OriginalString,
17 byte [] d1 = sk1.KeyData;
18 byte [] d2 = sk2.KeyData;
20 int len = d1.Length > d2.Length ? d2.Length : d1.Length;
21 for (int i = 0; i < len; i++)
23 return d1 [i] < d2 [i] ? -1 : 1;
24 return d1.Length == d2.Length ? 0 : d1.Length < d2.Length ? -1 : 1;
28 readonly string source;
29 readonly CompareOptions options;
33 // for legacy unmanaged one
34 internal SortKey (int lcid, string source, CompareOptions opt)
41 internal SortKey (int lcid, string source, byte [] buffer, CompareOptions opt,
42 int lv1Length, int lv2Length, int lv3Length,
43 int kanaSmallLength, int markTypeLength,
44 int katakanaLength, int kanaWidthLength,
53 public string OriginalString {
54 get { return source; }
57 public byte [] KeyData {
61 // copy from original SortKey.cs
62 public override bool Equals (object value)
64 SortKey other = (value as SortKey);
66 if((this.lcid==other.lcid) &&
67 (this.options==other.options) &&
68 (Compare (this, other)==0)) {
76 public override int GetHashCode ()
79 return 0; // should not happen though.
81 for (int i = 1; i < key.Length; i++)
82 val ^= (int) key [i] << (i & 3);
86 // copy from original SortKey.cs
87 public override string ToString()
89 return("SortKey - "+lcid+", "+options+", "+source);