mscorlib(4.0.0.0) API with additions
SortVersion.cs
1 namespace System.Globalization
2 {
5  public sealed class SortVersion : IEquatable<SortVersion>
6  {
7  private int m_NlsVersion;
8 
9  private Guid m_SortId;
10 
13  public int FullVersion => m_NlsVersion;
14 
17  public Guid SortId => m_SortId;
18 
22  public SortVersion(int fullVersion, Guid sortId)
23  {
24  m_SortId = sortId;
25  m_NlsVersion = fullVersion;
26  }
27 
28  internal SortVersion(int nlsVersion, int effectiveId, Guid customVersion)
29  {
30  m_NlsVersion = nlsVersion;
31  if (customVersion == Guid.Empty)
32  {
33  byte[] bytes = BitConverter.GetBytes(effectiveId);
34  byte h = (byte)((uint)effectiveId >> 24);
35  byte i = (byte)((effectiveId & 0xFF0000) >> 16);
36  byte j = (byte)((effectiveId & 0xFF00) >> 8);
37  byte k = (byte)(effectiveId & 0xFF);
38  customVersion = new Guid(0, 0, 0, 0, 0, 0, 0, h, i, j, k);
39  }
40  m_SortId = customVersion;
41  }
42 
47  public override bool Equals(object obj)
48  {
49  SortVersion sortVersion = obj as SortVersion;
50  if (sortVersion != null)
51  {
52  return Equals(sortVersion);
53  }
54  return false;
55  }
56 
61  public bool Equals(SortVersion other)
62  {
63  if (other == null)
64  {
65  return false;
66  }
67  if (m_NlsVersion == other.m_NlsVersion)
68  {
69  return m_SortId == other.m_SortId;
70  }
71  return false;
72  }
73 
76  public override int GetHashCode()
77  {
78  return (m_NlsVersion * 7) | m_SortId.GetHashCode();
79  }
80 
86  public static bool operator ==(SortVersion left, SortVersion right)
87  {
88  return left?.Equals(right) ?? right?.Equals(left) ?? true;
89  }
90 
96  public static bool operator !=(SortVersion left, SortVersion right)
97  {
98  return !(left == right);
99  }
100  }
101 }
int FullVersion
Gets the full version number of the T:System.Globalization.SortVersion object.
Definition: SortVersion.cs:13
bool Equals(SortVersion other)
Returns a value that indicates whether this T:System.Globalization.SortVersion instance is equal to a...
Definition: SortVersion.cs:61
Represents a globally unique identifier (GUID).To browse the .NET Framework source code for this type...
Definition: Guid.cs:14
Provides information about the version of Unicode used to compare and order strings.
Definition: SortVersion.cs:5
Converts base data types to an array of bytes, and an array of bytes to base data types.
Definition: BitConverter.cs:7
SortVersion(int fullVersion, Guid sortId)
Creates a new instance of the T:System.Globalization.SortVersion class.
Definition: SortVersion.cs:22
static bool operator==(SortVersion left, SortVersion right)
Indicates whether two T:System.Globalization.SortVersion instances are equal.
Definition: SortVersion.cs:86
static bool operator !=(SortVersion left, SortVersion right)
Indicates whether two T:System.Globalization.SortVersion instances are not equal.
Definition: SortVersion.cs:96
Guid SortId
Gets a globally unique identifier for this T:System.Globalization.SortVersion object.
Definition: SortVersion.cs:17
override int GetHashCode()
Returns the hash code for this instance.
Definition: Guid.cs:976
Defines a generalized method that a value type or class implements to create a type-specific method f...
Definition: IEquatable.cs:6
Specifies that the class can be serialized.
override int GetHashCode()
Returns a hash code for this instance.
Definition: SortVersion.cs:76
static readonly Guid Empty
A read-only instance of the T:System.Guid structure whose value is all zeros.
Definition: Guid.cs:126
override bool Equals(object obj)
Returns a value that indicates whether this T:System.Globalization.SortVersion instance is equal to a...
Definition: SortVersion.cs:47
static byte [] GetBytes(bool value)
Returns the specified Boolean value as a byte array.
Definition: BitConverter.cs:19