5 // Atsushi Enomoto <atsushi@ximian.com>
9 // Copyright (C) 2005 Novell, Inc (http://www.novell.com)
11 // Permission is hereby granted, free of charge, to any person obtaining
12 // a copy of this software and associated documentation files (the
13 // "Software"), to deal in the Software without restriction, including
14 // without limitation the rights to use, copy, modify, merge, publish,
15 // distribute, sublicense, and/or sell copies of the Software, and to
16 // permit persons to whom the Software is furnished to do so, subject to
17 // the following conditions:
19 // The above copyright notice and this permission notice shall be
20 // included in all copies or substantial portions of the Software.
22 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
23 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
24 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
25 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
26 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
27 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
28 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
30 using System.Globalization;
31 using System.Runtime.CompilerServices;
33 namespace System.Globalization
36 [System.Runtime.InteropServices.ComVisible(true)]
39 public class RegionInfo
41 static RegionInfo currentRegion;
43 // This property is not synchronized with CurrentCulture, so
44 // we need to use bootstrap CurrentCulture LCID.
45 public static RegionInfo CurrentRegion {
47 if (currentRegion == null) {
48 // make sure to fill BootstrapCultureID.
49 CultureInfo ci = CultureInfo.CurrentCulture;
50 // If current culture is invariant then region is not available.
51 if (ci == null || CultureInfo.BootstrapCultureID == 0x7F)
53 currentRegion = new RegionInfo (CultureInfo.BootstrapCultureID);
64 string currencySymbol;
65 string isoCurrencySymbol;
66 string currencyEnglishName;
68 public RegionInfo (int lcid)
70 if (!construct_internal_region_from_lcid (lcid))
71 throw new ArgumentException (
72 String.Format ("Region ID {0} (0x{0:X4}) is not a " +
73 "supported region.", lcid), "lcid");
76 public RegionInfo (string name)
79 throw new ArgumentNullException ();
81 if (!construct_internal_region_from_name (name.ToUpperInvariant ()))
82 throw new ArgumentException ("Region name " + name +
83 " is not supported.", "name");
86 [MethodImplAttribute (MethodImplOptions.InternalCall)]
87 private extern bool construct_internal_region_from_lcid (int lcid);
89 [MethodImplAttribute (MethodImplOptions.InternalCall)]
90 private extern bool construct_internal_region_from_name (string name);
93 [System.Runtime.InteropServices.ComVisible(false)]
94 public virtual string CurrencyEnglishName {
95 get { return currencyEnglishName; }
99 public virtual string CurrencySymbol {
100 get { return currencySymbol; }
103 [MonoTODO ("DisplayName currently only returns the EnglishName")]
104 public virtual string DisplayName {
105 get { return englishName; }
108 public virtual string EnglishName {
109 get { return englishName; }
112 public virtual bool IsMetric {
124 public virtual string ISOCurrencySymbol {
125 get { return isoCurrencySymbol; }
130 [System.Runtime.InteropServices.ComVisible(false)]
131 public virtual string NativeName {
132 get { return DisplayName; }
135 [MonoTODO ("Not implemented")]
136 public virtual string CurrencyNativeName {
137 get { throw new NotImplementedException (); }
141 public virtual string Name {
142 get { return iso2Name; }
145 public virtual string ThreeLetterISORegionName {
146 get { return iso3Name; }
149 public virtual string ThreeLetterWindowsRegionName {
150 get { return win3Name; }
153 public virtual string TwoLetterISORegionName {
154 get { return iso2Name; }
162 public override bool Equals (object value)
164 RegionInfo other = value as RegionInfo;
165 return other != null && regionId == other.regionId;
168 public override int GetHashCode () {
173 public override string ToString ()