2 using System.Diagnostics.Contracts;
4 namespace System.Globalization {
7 public sealed class SortVersion : IEquatable<SortVersion> {
9 private int m_NlsVersion;
10 private Guid m_SortId;
12 public int FullVersion {
24 public SortVersion(int fullVersion, Guid sortId) {
26 m_NlsVersion = fullVersion;
29 internal SortVersion(int nlsVersion, int effectiveId, Guid customVersion) {
30 m_NlsVersion = nlsVersion;
32 if(customVersion == Guid.Empty) {
33 byte[] b = BitConverter.GetBytes(effectiveId);
34 byte b1 = (byte) ((uint) effectiveId >> 24);
35 byte b2 = (byte) ((effectiveId & 0x00FF0000) >> 16);
36 byte b3 = (byte) ((effectiveId & 0x0000FF00) >> 8);
37 byte b4 = (byte) (effectiveId & 0xFF);
38 customVersion = new Guid(0,0,0,0,0,0,0,b1,b2,b3,b4);
41 m_SortId = customVersion;
44 public override bool Equals(object obj) {
45 SortVersion n = obj as SortVersion;
47 return this.Equals(n);
53 public bool Equals(SortVersion other) {
58 return m_NlsVersion == other.m_NlsVersion && m_SortId == other.m_SortId;
61 public override int GetHashCode() {
62 return m_NlsVersion * 7 | m_SortId.GetHashCode();
65 public static bool operator ==(SortVersion left, SortVersion right) {
66 if (((object) left) != null) {
67 return left.Equals(right);
70 if (((object) right) != null) {
71 return right.Equals(left);
78 public static bool operator !=(SortVersion left, SortVersion right) {
79 return !(left == right);