1 // Licensed to the .NET Foundation under one or more agreements.
2 // The .NET Foundation licenses this file to you under the MIT license.
3 // See the LICENSE file in the project root for more information.
5 namespace System.Globalization
8 using System.Diagnostics.Contracts;
11 public sealed class SortVersion : IEquatable<SortVersion>
13 private int m_NlsVersion;
14 private Guid m_SortId;
16 public int FullVersion
32 public SortVersion(int fullVersion, Guid sortId)
35 m_NlsVersion = fullVersion;
38 internal SortVersion(int nlsVersion, int effectiveId, Guid customVersion)
40 m_NlsVersion = nlsVersion;
42 if (customVersion == Guid.Empty)
44 byte[] b = BitConverter.GetBytes(effectiveId);
45 byte b1 = (byte) ((uint) effectiveId >> 24);
46 byte b2 = (byte) ((effectiveId & 0x00FF0000) >> 16);
47 byte b3 = (byte) ((effectiveId & 0x0000FF00) >> 8);
48 byte b4 = (byte) (effectiveId & 0xFF);
49 customVersion = new Guid(0,0,0,0,0,0,0,b1,b2,b3,b4);
52 m_SortId = customVersion;
55 public override bool Equals(object obj)
57 SortVersion n = obj as SortVersion;
60 return this.Equals(n);
66 public bool Equals(SortVersion other)
73 return m_NlsVersion == other.m_NlsVersion && m_SortId == other.m_SortId;
76 public override int GetHashCode()
78 return m_NlsVersion * 7 | m_SortId.GetHashCode();
81 public static bool operator ==(SortVersion left, SortVersion right)
83 if (((object) left) != null)
85 return left.Equals(right);
88 if (((object) right) != null)
90 return right.Equals(left);
97 public static bool operator !=(SortVersion left, SortVersion right)
99 return !(left == right);