summaryrefslogtreecommitdiff
path: root/src/mscorlib/corefx/System/Globalization/RegionInfo.cs
diff options
context:
space:
mode:
Diffstat (limited to 'src/mscorlib/corefx/System/Globalization/RegionInfo.cs')
-rw-r--r--src/mscorlib/corefx/System/Globalization/RegionInfo.cs117
1 files changed, 108 insertions, 9 deletions
diff --git a/src/mscorlib/corefx/System/Globalization/RegionInfo.cs b/src/mscorlib/corefx/System/Globalization/RegionInfo.cs
index 0669349040..0645ded0ab 100644
--- a/src/mscorlib/corefx/System/Globalization/RegionInfo.cs
+++ b/src/mscorlib/corefx/System/Globalization/RegionInfo.cs
@@ -14,15 +14,14 @@
//
////////////////////////////////////////////////////////////////////////////
-using System;
+using System.Diagnostics;
using System.Diagnostics.Contracts;
using System.Runtime.Serialization;
namespace System.Globalization
{
[Serializable]
- [System.Runtime.InteropServices.ComVisible(true)]
- public partial class RegionInfo
+ public class RegionInfo
{
//--------------------------------------------------------------------//
// Internal Information //
@@ -61,11 +60,11 @@ namespace System.Globalization
public RegionInfo(String name)
{
if (name == null)
- throw new ArgumentNullException("name");
+ throw new ArgumentNullException(nameof(name));
if (name.Length == 0) //The InvariantCulture has no matching region
{
- throw new ArgumentException(SR.Argument_NoRegionInvariantCulture, "name");
+ throw new ArgumentException(SR.Argument_NoRegionInvariantCulture, nameof(name));
}
Contract.EndContractBlock();
@@ -78,16 +77,46 @@ namespace System.Globalization
throw new ArgumentException(
String.Format(
CultureInfo.CurrentCulture,
- SR.Argument_InvalidCultureName, name), "name");
+ SR.Argument_InvalidCultureName, name), nameof(name));
// Not supposed to be neutral
if (_cultureData.IsNeutralCulture)
- throw new ArgumentException(SR.Format(SR.Argument_InvalidNeutralRegionName, name), "name");
+ throw new ArgumentException(SR.Format(SR.Argument_InvalidNeutralRegionName, name), nameof(name));
SetName(name);
}
+ [System.Security.SecuritySafeCritical] // auto-generated
+ public RegionInfo(int culture)
+ {
+ if (culture == CultureInfo.LOCALE_INVARIANT) //The InvariantCulture has no matching region
+ {
+ throw new ArgumentException(SR.Argument_NoRegionInvariantCulture);
+ }
+
+ if (culture == CultureInfo.LOCALE_NEUTRAL)
+ {
+ // Not supposed to be neutral
+ throw new ArgumentException(SR.Format(SR.Argument_CultureIsNeutral, culture), nameof(culture));
+ }
+
+ if (culture == CultureInfo.LOCALE_CUSTOM_DEFAULT)
+ {
+ // Not supposed to be neutral
+ throw new ArgumentException(SR.Format(SR.Argument_CustomCultureCannotBePassedByNumber, culture), nameof(culture));
+ }
+
+ _cultureData = CultureData.GetCultureData(culture, true);
+ _name = _cultureData.SREGIONNAME;
+
+ if (_cultureData.IsNeutralCulture)
+ {
+ // Not supposed to be neutral
+ throw new ArgumentException(SR.Format(SR.Argument_CultureIsNeutral, culture), nameof(culture));
+ }
+ }
+
internal RegionInfo(CultureData cultureData)
{
_cultureData = cultureData;
@@ -156,7 +185,7 @@ namespace System.Globalization
{
get
{
- Contract.Assert(_name != null, "Expected RegionInfo._name to be populated already");
+ Debug.Assert(_name != null, "Expected RegionInfo._name to be populated already");
return (_name);
}
}
@@ -202,7 +231,6 @@ namespace System.Globalization
// WARNING: You need a full locale name for this to make sense.
//
////////////////////////////////////////////////////////////////////////
- [System.Runtime.InteropServices.ComVisible(false)]
public virtual String NativeName
{
get
@@ -228,6 +256,38 @@ namespace System.Globalization
////////////////////////////////////////////////////////////////////////
//
+ // ThreeLetterISORegionName
+ //
+ // Returns the three letter ISO region name (ie: USA)
+ //
+ ////////////////////////////////////////////////////////////////////////
+ public virtual String ThreeLetterISORegionName
+ {
+ get
+ {
+ return (_cultureData.SISO3166CTRYNAME2);
+ }
+ }
+
+ ////////////////////////////////////////////////////////////////////////
+ //
+ // ThreeLetterWindowsRegionName
+ //
+ // Returns the three letter windows region name (ie: USA)
+ //
+ ////////////////////////////////////////////////////////////////////////
+ public virtual String ThreeLetterWindowsRegionName
+ {
+ get
+ {
+ // ThreeLetterWindowsRegionName is really same as ThreeLetterISORegionName
+ return ThreeLetterISORegionName;
+ }
+ }
+
+
+ ////////////////////////////////////////////////////////////////////////
+ //
// IsMetric
//
// Returns true if this region uses the metric measurement system
@@ -242,6 +302,45 @@ namespace System.Globalization
}
}
+ public virtual int GeoId
+ {
+ get
+ {
+ return (_cultureData.IGEOID);
+ }
+ }
+
+ ////////////////////////////////////////////////////////////////////////
+ //
+ // CurrencyEnglishName
+ //
+ // English name for this region's currency, ie: Swiss Franc
+ //
+ ////////////////////////////////////////////////////////////////////////
+ public virtual string CurrencyEnglishName
+ {
+ get
+ {
+ return (_cultureData.SENGLISHCURRENCY);
+ }
+ }
+
+ ////////////////////////////////////////////////////////////////////////
+ //
+ // CurrencyNativeName
+ //
+ // Native name for this region's currency, ie: Schweizer Franken
+ // WARNING: You need a full locale name for this to make sense.
+ //
+ ////////////////////////////////////////////////////////////////////////
+ public virtual string CurrencyNativeName
+ {
+ get
+ {
+ return (_cultureData.SNATIVECURRENCY);
+ }
+ }
+
////////////////////////////////////////////////////////////////////////
//
// CurrencySymbol