We need you! We're working hard on the next version of Developer Fusion -
Let us know what you think we should be up to!
- ////////////////////////////////////////////////////////////////////////////
- ////////////////////////////////////////////////////////////////////////////
- namespace System.Globalization
- {
-
- using System;
- using System.Runtime.Serialization;
-
- [Serializable()]
- [System.Runtime.InteropServices.ComVisible(true)]
- public class RegionInfo
- {
-
-
-
-
-
-
-
- internal string m_name;
-
-
-
-
-
-
- [OptionalField(VersionAdded = 2)]
- int m_cultureId;
-
-
-
-
-
-
- [NonSerialized()]
- internal CultureTableRecord m_cultureTableRecord;
-
- static internal RegionInfo m_currentRegionInfo;
-
-
- ////////////////////////////////////////////////////////////////////////
-
-
-
- ////////////////////////////////////////////////////////////////////////
-
-
- public RegionInfo(string name)
- {
- if (name == null)
- throw new ArgumentNullException("name");
- if (name.Length == 0)
- throw new ArgumentException(Environment.GetResourceString("Argument_InvalidRegionName", name), "name");
- this.m_name = name.ToUpper(CultureInfo.InvariantCulture);
-
- m_cultureId = 0;
-
-
-
-
-
-
- this.m_cultureTableRecord = CultureTableRecord.GetCultureTableRecordForRegion(name, true);
-
- if (this.m_cultureTableRecord.IsNeutralCulture) {
-
- throw new ArgumentException(Environment.GetResourceString("Argument_InvalidNeutralRegionName", name), "name");
- }
- }
-
-
- public RegionInfo(int culture)
- {
-
-
- if (culture == CultureInfo.LOCALE_INVARIANT) {
-
- throw new ArgumentException(Environment.GetResourceString("Argument_NoRegionInvariantCulture"));
- }
-
- if (CultureTableRecord.IsCustomCultureId(culture)) {
-
- throw new ArgumentException(Environment.GetResourceString("Argument_CustomCultureCannotBePassedByNumber", "culture"));
- }
- if (CultureInfo.GetSubLangID(culture) == 0) {
-
- throw new ArgumentException(Environment.GetResourceString("Argument_CultureIsNeutral", culture), "culture");
- }
-
-
-
-
-
-
-
- this.m_cultureTableRecord = CultureTableRecord.GetCultureTableRecord(culture, true);
-
- if (this.m_cultureTableRecord.IsNeutralCulture) {
-
- throw new ArgumentException(Environment.GetResourceString("Argument_CultureIsNeutral", culture), "culture");
- }
-
-
- this.m_name = this.m_cultureTableRecord.SREGIONNAME;
-
- m_cultureId = culture;
- }
-
- internal RegionInfo(CultureTableRecord table)
- {
- this.m_cultureTableRecord = table;
-
- this.m_name = this.m_cultureTableRecord.SREGIONNAME;
- }
-
- #region Serialization
- internal int m_dataItem;
-
- [OnDeserialized()]
- private void OnDeserialized(StreamingContext ctx)
- {
- if (m_name == null) {
- BCLDebug.Assert(m_dataItem >= 0, "[RegionInfo.OnDeserialized] null name and invalid dataItem");
- m_cultureTableRecord = CultureTableRecord.GetCultureTableRecord(CultureTableRecord.IdFromEverettRegionInfoDataItem(m_dataItem), true);
- m_name = m_cultureTableRecord.SREGIONNAME;
- }
- else {
- if (m_cultureId != 0)
- m_cultureTableRecord = CultureTableRecord.GetCultureTableRecord(m_cultureId, true);
- else
- m_cultureTableRecord = CultureTableRecord.GetCultureTableRecordForRegion(m_name, true);
- }
- }
-
- [OnSerializing()]
- private void OnSerializing(StreamingContext ctx)
- {
- m_dataItem = m_cultureTableRecord.EverettRegionDataItem();
- }
- #endregion Serialization
-
- ////////////////////////////////////////////////////////////////////////
-
-
-
-
-
-
-
- ////////////////////////////////////////////////////////////////////////
-
-
- unsafe public static RegionInfo CurrentRegion {
- get {
- RegionInfo temp = m_currentRegionInfo;
- if (temp == null) {
- temp = new RegionInfo(CultureInfo.CurrentCulture.m_cultureTableRecord);
-
-
- if (temp.m_cultureTableRecord.IsCustomCulture) {
- temp.m_name = temp.m_cultureTableRecord.SNAME;
- }
- m_currentRegionInfo = temp;
- }
- return temp;
- }
- }
-
- ////////////////////////////////////////////////////////////////////////
-
-
-
-
-
- ////////////////////////////////////////////////////////////////////////
-
-
- public virtual string Name {
- get {
- if (m_name == null) {
- m_name = this.m_cultureTableRecord.SREGIONNAME;
- }
- return (m_name);
- }
- }
-
- ////////////////////////////////////////////////////////////////////////
-
-
-
-
-
- ////////////////////////////////////////////////////////////////////////
-
-
- public virtual string EnglishName {
- get { return (this.m_cultureTableRecord.SENGCOUNTRY); }
- }
-
-
- public virtual string DisplayName {
- get {
- if (m_cultureTableRecord.IsCustomCulture) {
- if (m_cultureTableRecord.IsReplacementCulture) {
-
- if (m_cultureTableRecord.IsSynthetic)
- return m_cultureTableRecord.RegionNativeDisplayName;
- else
- return (Environment.GetResourceString("Globalization.ri_" + this.m_cultureTableRecord.SREGIONNAME));
- }
- else {
- return this.m_cultureTableRecord.SNATIVECOUNTRY;
- }
- }
- else {
-
- if (m_cultureTableRecord.IsSynthetic)
- return m_cultureTableRecord.RegionNativeDisplayName;
- else
- return (Environment.GetResourceString("Globalization.ri_" + this.m_cultureTableRecord.SREGIONNAME));
- }
- }
- }
-
-
- [System.Runtime.InteropServices.ComVisible(false)]
- public virtual string NativeName {
- get { return (this.m_cultureTableRecord.SNATIVECOUNTRY); }
- }
-
-
- public virtual string TwoLetterISORegionName {
- get { return (this.m_cultureTableRecord.SISO3166CTRYNAME); }
- }
-
-
- public virtual string ThreeLetterISORegionName {
- get { return (this.m_cultureTableRecord.SISO3166CTRYNAME2); }
- }
-
-
- public virtual bool IsMetric {
- get {
- int value = this.m_cultureTableRecord.IMEASURE;
- return (value == 0);
- }
- }
-
-
- [System.Runtime.InteropServices.ComVisible(false)]
- public virtual int GeoId {
- get { return (this.m_cultureTableRecord.IGEOID); }
- }
-
-
- public virtual string ThreeLetterWindowsRegionName {
- get { return (this.m_cultureTableRecord.SABBREVCTRYNAME); }
- }
-
-
- [System.Runtime.InteropServices.ComVisible(false)]
- public virtual string CurrencyEnglishName {
- get { return (this.m_cultureTableRecord.SENGLISHCURRENCY); }
- }
-
-
- [System.Runtime.InteropServices.ComVisible(false)]
- public virtual string CurrencyNativeName {
- get { return (this.m_cultureTableRecord.SNATIVECURRENCY); }
- }
-
-
-
-
- public virtual string CurrencySymbol {
- get { return (this.m_cultureTableRecord.SCURRENCY); }
- }
-
-
-
-
- public virtual string ISOCurrencySymbol {
- get { return (this.m_cultureTableRecord.SINTLSYMBOL); }
- }
-
- ////////////////////////////////////////////////////////////////////////
-
-
-
-
-
-
- ////////////////////////////////////////////////////////////////////////
-
-
- public override bool Equals(object value)
- {
- RegionInfo that = value as RegionInfo;
- if (that != null) {
- return this.Name.Equals(that.Name);
- }
-
- return (false);
- }
-
- ////////////////////////////////////////////////////////////////////////
-
-
-
-
-
-
-
- ////////////////////////////////////////////////////////////////////////
-
-
- public override int GetHashCode()
- {
- return (this.Name.GetHashCode());
- }
-
-
- ////////////////////////////////////////////////////////////////////////
-
-
-
-
-
-
- ////////////////////////////////////////////////////////////////////////
-
-
- public override string ToString()
- {
- return (Name);
- }
- }
- }