Expose missing Global/Encoding APIs in coreclr and remove empty stubs
[platform/upstream/coreclr.git] / src / mscorlib / src / System / Globalization / SortVersion.cs
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.
4
5 namespace System.Globalization 
6 {
7     using System;
8     using System.Diagnostics.Contracts;
9
10     [Serializable]
11     public sealed class SortVersion : IEquatable<SortVersion> 
12     {
13         private int m_NlsVersion;
14         private Guid m_SortId;
15
16         public int FullVersion 
17         {
18             get 
19             {
20                 return m_NlsVersion;
21             }
22         }
23
24         public Guid SortId 
25         {
26             get 
27             {
28                 return m_SortId;
29             }
30         }
31
32         public SortVersion(int fullVersion, Guid sortId) 
33         {           
34             m_SortId = sortId;
35             m_NlsVersion = fullVersion;
36         }
37
38         internal SortVersion(int nlsVersion, int effectiveId, Guid customVersion) 
39         {
40             m_NlsVersion = nlsVersion;
41
42             if (customVersion == Guid.Empty) 
43             {
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);
50             }
51
52             m_SortId = customVersion;
53         }
54
55         public override bool Equals(object obj) 
56         {
57             SortVersion n = obj as SortVersion;
58             if(n != null) 
59             {
60                 return this.Equals(n);
61             }
62
63             return false;
64         }
65
66         public bool Equals(SortVersion other) 
67         {
68             if (other == null) 
69             {
70                 return false;
71             }
72
73             return m_NlsVersion == other.m_NlsVersion && m_SortId == other.m_SortId;
74         }
75
76         public override int GetHashCode() 
77         { 
78             return m_NlsVersion * 7 | m_SortId.GetHashCode(); 
79         }
80
81         public static bool operator ==(SortVersion left, SortVersion right) 
82         {
83             if (((object) left) != null) 
84             {
85                 return left.Equals(right);
86             }
87
88             if (((object) right) != null) 
89             {
90                 return right.Equals(left);
91             }
92
93             // Both null.
94             return true;
95         }
96
97         public static bool operator !=(SortVersion left, SortVersion right) 
98         {
99             return !(left == right);
100         }
101     }
102 }