Files
2026-06-04 11:42:34 +02:00

1217 lines
47 KiB
C#

using System;
using System.Collections;
using System.Collections.Generic;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Threading;
namespace System.Globalization
{
/// <summary>Provides information about a specific culture (called a "locale" for unmanaged code development). The information includes the names for the culture, the writing system, the calendar used, and formatting for dates and sort strings.</summary>
// Token: 0x0200017E RID: 382
[ComVisible(true)]
[Serializable]
public class CultureInfo : ICloneable, IFormatProvider
{
/// <summary>Initializes a new instance of the <see cref="T:System.Globalization.CultureInfo" /> class based on the culture specified by the culture identifier.</summary>
/// <param name="culture">A predefined <see cref="T:System.Globalization.CultureInfo" /> identifier, <see cref="P:System.Globalization.CultureInfo.LCID" /> property of an existing <see cref="T:System.Globalization.CultureInfo" /> object, or Windows-only culture identifier. </param>
/// <exception cref="T:System.ArgumentOutOfRangeException">
/// <paramref name="culture" /> is less than zero. </exception>
/// <exception cref="T:System.ArgumentException">
/// <paramref name="culture" /> is not a valid culture identifier. -or-In .NET Compact Framework applications, <paramref name="culture" /> is not supported by the operating system of the device. </exception>
// Token: 0x06001282 RID: 4738 RVA: 0x00048CD0 File Offset: 0x00046ED0
public CultureInfo(int culture)
: this(culture, true)
{
}
/// <summary>Initializes a new instance of the <see cref="T:System.Globalization.CultureInfo" /> class based on the culture specified by the culture identifier and on the Boolean that specifies whether to use the user-selected culture settings from the system.</summary>
/// <param name="culture">A predefined <see cref="T:System.Globalization.CultureInfo" /> identifier, <see cref="P:System.Globalization.CultureInfo.LCID" /> property of an existing <see cref="T:System.Globalization.CultureInfo" /> object, or Windows-only culture identifier. </param>
/// <param name="useUserOverride">A Boolean that denotes whether to use the user-selected culture settings (true) or the default culture settings (false). </param>
/// <exception cref="T:System.ArgumentOutOfRangeException">
/// <paramref name="culture" /> is less than zero. </exception>
/// <exception cref="T:System.ArgumentException">
/// <paramref name="culture" /> is not a valid culture identifier.-or-In .NET Compact Framework applications, <paramref name="culture" /> is not supported by the operating system of the device. </exception>
// Token: 0x06001283 RID: 4739 RVA: 0x00048CDC File Offset: 0x00046EDC
public CultureInfo(int culture, bool useUserOverride)
: this(culture, useUserOverride, false)
{
}
// Token: 0x06001284 RID: 4740 RVA: 0x00048CE8 File Offset: 0x00046EE8
private CultureInfo(int culture, bool useUserOverride, bool read_only)
{
if (culture < 0)
{
throw new ArgumentOutOfRangeException("culture", "Positive number required.");
}
this.constructed = true;
this.m_isReadOnly = read_only;
this.m_useUserOverride = useUserOverride;
if (culture == 127)
{
this.ConstructInvariant(read_only);
return;
}
if (!this.ConstructInternalLocaleFromLcid(culture))
{
throw new ArgumentException(string.Format("Culture ID {0} (0x{0:X4}) is not a supported culture.", culture), "culture");
}
}
/// <summary>Initializes a new instance of the <see cref="T:System.Globalization.CultureInfo" /> class based on the culture specified by name.</summary>
/// <param name="name">A predefined <see cref="T:System.Globalization.CultureInfo" /> name, <see cref="P:System.Globalization.CultureInfo.Name" /> of an existing <see cref="T:System.Globalization.CultureInfo" />, or Windows-only culture name. </param>
/// <exception cref="T:System.ArgumentNullException">
/// <paramref name="name" /> is null. </exception>
/// <exception cref="T:System.ArgumentException">
/// <paramref name="name" /> is not a valid culture name. -or-In .NET Compact Framework applications, <paramref name="culture" /> is not supported by the operating system of the device.</exception>
// Token: 0x06001285 RID: 4741 RVA: 0x00048D60 File Offset: 0x00046F60
public CultureInfo(string name)
: this(name, true)
{
}
/// <summary>Initializes a new instance of the <see cref="T:System.Globalization.CultureInfo" /> class based on the culture specified by name and on the Boolean that specifies whether to use the user-selected culture settings from the system.</summary>
/// <param name="name">A predefined <see cref="T:System.Globalization.CultureInfo" /> name, <see cref="P:System.Globalization.CultureInfo.Name" /> of an existing <see cref="T:System.Globalization.CultureInfo" />, or Windows-only culture name. </param>
/// <param name="useUserOverride">A Boolean that denotes whether to use the user-selected culture settings (true) or the default culture settings (false). </param>
/// <exception cref="T:System.ArgumentNullException">
/// <paramref name="name" /> is null. </exception>
/// <exception cref="T:System.ArgumentException">
/// <paramref name="name" /> is not a valid culture name. -or-In .NET Compact Framework applications, <paramref name="culture" /> is not supported by the operating system of the device.</exception>
// Token: 0x06001286 RID: 4742 RVA: 0x00048D6C File Offset: 0x00046F6C
public CultureInfo(string name, bool useUserOverride)
: this(name, useUserOverride, false)
{
}
// Token: 0x06001287 RID: 4743 RVA: 0x00048D78 File Offset: 0x00046F78
private CultureInfo(string name, bool useUserOverride, bool read_only)
{
if (name == null)
{
throw new ArgumentNullException("name");
}
this.constructed = true;
this.m_isReadOnly = read_only;
this.m_useUserOverride = useUserOverride;
if (name.Length == 0)
{
this.ConstructInvariant(read_only);
return;
}
if (!this.ConstructInternalLocaleFromName(name.ToLowerInvariant()))
{
throw new ArgumentException("Culture name " + name + " is not supported.", "name");
}
}
// Token: 0x06001288 RID: 4744 RVA: 0x00048DF0 File Offset: 0x00046FF0
private CultureInfo()
{
this.constructed = true;
}
/// <summary>Gets the <see cref="T:System.Globalization.CultureInfo" /> that is culture-independent (invariant).</summary>
/// <returns>The <see cref="T:System.Globalization.CultureInfo" /> that is culture-independent (invariant).</returns>
// Token: 0x1700030F RID: 783
// (get) Token: 0x0600128A RID: 4746 RVA: 0x00048E34 File Offset: 0x00047034
public static CultureInfo InvariantCulture
{
get
{
return CultureInfo.invariant_culture_info;
}
}
/// <summary>Creates a <see cref="T:System.Globalization.CultureInfo" /> object that represents the specific culture that is associated with the specified name.</summary>
/// <returns>A <see cref="T:System.Globalization.CultureInfo" /> object that represents:The invariant culture, if <paramref name="name" /> is an empty string ("").-or- The specific culture associated with <paramref name="name" />, if <paramref name="name" /> is a neutral culture.-or- The culture specified by <paramref name="name" />, if <paramref name="name" /> is already a specific culture.</returns>
/// <param name="name">A predefined <see cref="T:System.Globalization.CultureInfo" /> name or the name of an existing <see cref="T:System.Globalization.CultureInfo" /> object. </param>
/// <exception cref="T:System.ArgumentException">
/// <paramref name="name" /> is not a valid culture name.-or- The culture specified by <paramref name="name" /> does not have a specific culture associated with it. </exception>
/// <exception cref="T:System.NullReferenceException">
/// <paramref name="name" /> is null. </exception>
// Token: 0x0600128B RID: 4747 RVA: 0x00048E40 File Offset: 0x00047040
public static CultureInfo CreateSpecificCulture(string name)
{
if (name == null)
{
throw new ArgumentNullException("name");
}
if (name == string.Empty)
{
return CultureInfo.InvariantCulture;
}
CultureInfo cultureInfo = new CultureInfo();
if (!CultureInfo.ConstructInternalLocaleFromSpecificName(cultureInfo, name.ToLowerInvariant()))
{
throw new ArgumentException("Culture name " + name + " is not supported.", name);
}
return cultureInfo;
}
/// <summary>Gets the <see cref="T:System.Globalization.CultureInfo" /> that represents the culture used by the current thread.</summary>
/// <returns>The <see cref="T:System.Globalization.CultureInfo" /> that represents the culture used by the current thread.</returns>
// Token: 0x17000310 RID: 784
// (get) Token: 0x0600128C RID: 4748 RVA: 0x00048EA4 File Offset: 0x000470A4
public static CultureInfo CurrentCulture
{
get
{
return Thread.CurrentThread.CurrentCulture;
}
}
/// <summary>Gets the <see cref="T:System.Globalization.CultureInfo" /> that represents the current culture used by the Resource Manager to look up culture-specific resources at run time.</summary>
/// <returns>The <see cref="T:System.Globalization.CultureInfo" /> that represents the current culture used by the Resource Manager to look up culture-specific resources at run time.</returns>
/// <PermissionSet>
/// <IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="UnmanagedCode" />
/// </PermissionSet>
// Token: 0x17000311 RID: 785
// (get) Token: 0x0600128D RID: 4749 RVA: 0x00048EB0 File Offset: 0x000470B0
public static CultureInfo CurrentUICulture
{
get
{
return Thread.CurrentThread.CurrentUICulture;
}
}
// Token: 0x0600128E RID: 4750 RVA: 0x00048EBC File Offset: 0x000470BC
internal static CultureInfo ConstructCurrentCulture()
{
CultureInfo cultureInfo = new CultureInfo();
if (!CultureInfo.ConstructInternalLocaleFromCurrentLocale(cultureInfo))
{
cultureInfo = CultureInfo.InvariantCulture;
}
CultureInfo.BootstrapCultureID = cultureInfo.cultureID;
return cultureInfo;
}
// Token: 0x0600128F RID: 4751 RVA: 0x00048EEC File Offset: 0x000470EC
internal static CultureInfo ConstructCurrentUICulture()
{
return CultureInfo.ConstructCurrentCulture();
}
// Token: 0x17000312 RID: 786
// (get) Token: 0x06001290 RID: 4752 RVA: 0x00048EF4 File Offset: 0x000470F4
internal string Territory
{
get
{
return this.territory;
}
}
/// <summary>Gets the culture identifier for the current <see cref="T:System.Globalization.CultureInfo" />.</summary>
/// <returns>The culture identifier for the current <see cref="T:System.Globalization.CultureInfo" />.</returns>
// Token: 0x17000313 RID: 787
// (get) Token: 0x06001291 RID: 4753 RVA: 0x00048EFC File Offset: 0x000470FC
public virtual int LCID
{
get
{
return this.cultureID;
}
}
/// <summary>Gets the culture name in the format "&lt;languagecode2&gt;-&lt;country/regioncode2&gt;".</summary>
/// <returns>The culture name in the format "&lt;languagecode2&gt;-&lt;country/regioncode2&gt;", where &lt;languagecode2&gt; is a lowercase two-letter code derived from ISO 639-1 and &lt;country/regioncode2&gt; is an uppercase two-letter code derived from ISO 3166.</returns>
// Token: 0x17000314 RID: 788
// (get) Token: 0x06001292 RID: 4754 RVA: 0x00048F04 File Offset: 0x00047104
public virtual string Name
{
get
{
return this.m_name;
}
}
/// <summary>Gets the culture name, consisting of the language, the country/region, and the optional script, that the culture is set to display.</summary>
/// <returns>The culture name. consisting of the full name of the language, the full name of the country/region, and the optional script. The format is discussed in the description of the <see cref="T:System.Globalization.CultureInfo" /> class.</returns>
// Token: 0x17000315 RID: 789
// (get) Token: 0x06001293 RID: 4755 RVA: 0x00048F0C File Offset: 0x0004710C
public virtual string NativeName
{
get
{
if (!this.constructed)
{
this.Construct();
}
return this.nativename;
}
}
/// <summary>Gets the default calendar used by the culture.</summary>
/// <returns>A <see cref="T:System.Globalization.Calendar" /> that represents the default calendar used by the culture.</returns>
// Token: 0x17000316 RID: 790
// (get) Token: 0x06001294 RID: 4756 RVA: 0x00048F28 File Offset: 0x00047128
public virtual Calendar Calendar
{
get
{
return this.DateTimeFormat.Calendar;
}
}
/// <summary>Gets the list of calendars that can be used by the culture.</summary>
/// <returns>An array of type <see cref="T:System.Globalization.Calendar" /> that represents the calendars that can be used by the culture represented by the current <see cref="T:System.Globalization.CultureInfo" />.</returns>
// Token: 0x17000317 RID: 791
// (get) Token: 0x06001295 RID: 4757 RVA: 0x00048F38 File Offset: 0x00047138
public virtual Calendar[] OptionalCalendars
{
get
{
if (this.optional_calendars == null)
{
lock (this)
{
if (this.optional_calendars == null)
{
this.ConstructCalendars();
}
}
}
return this.optional_calendars;
}
}
/// <summary>Gets the <see cref="T:System.Globalization.CultureInfo" /> that represents the parent culture of the current <see cref="T:System.Globalization.CultureInfo" />.</summary>
/// <returns>The <see cref="T:System.Globalization.CultureInfo" /> that represents the parent culture of the current <see cref="T:System.Globalization.CultureInfo" />.</returns>
/// <PermissionSet>
/// <IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="UnmanagedCode" />
/// </PermissionSet>
// Token: 0x17000318 RID: 792
// (get) Token: 0x06001296 RID: 4758 RVA: 0x00048F98 File Offset: 0x00047198
public virtual CultureInfo Parent
{
get
{
if (this.parent_culture == null)
{
if (!this.constructed)
{
this.Construct();
}
if (this.parent_lcid == this.cultureID)
{
return null;
}
if (this.parent_lcid == 127)
{
this.parent_culture = CultureInfo.InvariantCulture;
}
else if (this.cultureID == 127)
{
this.parent_culture = this;
}
else
{
this.parent_culture = new CultureInfo(this.parent_lcid);
}
}
return this.parent_culture;
}
}
/// <summary>Gets the <see cref="T:System.Globalization.TextInfo" /> that defines the writing system associated with the culture.</summary>
/// <returns>The <see cref="T:System.Globalization.TextInfo" /> that defines the writing system associated with the culture.</returns>
/// <PermissionSet>
/// <IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="UnmanagedCode" />
/// </PermissionSet>
// Token: 0x17000319 RID: 793
// (get) Token: 0x06001297 RID: 4759 RVA: 0x00049024 File Offset: 0x00047224
public virtual TextInfo TextInfo
{
get
{
if (this.textInfo == null)
{
if (!this.constructed)
{
this.Construct();
}
lock (this)
{
if (this.textInfo == null)
{
this.textInfo = this.CreateTextInfo(this.m_isReadOnly);
}
}
}
return this.textInfo;
}
}
/// <summary>Gets the ISO 639-2 three-letter code for the language of the current <see cref="T:System.Globalization.CultureInfo" />.</summary>
/// <returns>The ISO 639-2 three-letter code for the language of the current <see cref="T:System.Globalization.CultureInfo" />.</returns>
// Token: 0x1700031A RID: 794
// (get) Token: 0x06001298 RID: 4760 RVA: 0x000490A8 File Offset: 0x000472A8
public virtual string ThreeLetterISOLanguageName
{
get
{
if (!this.constructed)
{
this.Construct();
}
return this.iso3lang;
}
}
/// <summary>Gets the three-letter code for the language as defined in the Windows API.</summary>
/// <returns>The three-letter code for the language as defined in the Windows API.</returns>
// Token: 0x1700031B RID: 795
// (get) Token: 0x06001299 RID: 4761 RVA: 0x000490C4 File Offset: 0x000472C4
public virtual string ThreeLetterWindowsLanguageName
{
get
{
if (!this.constructed)
{
this.Construct();
}
return this.win3lang;
}
}
/// <summary>Gets the ISO 639-1 two-letter code for the language of the current <see cref="T:System.Globalization.CultureInfo" />.</summary>
/// <returns>The ISO 639-1 two-letter code for the language of the current <see cref="T:System.Globalization.CultureInfo" />.</returns>
// Token: 0x1700031C RID: 796
// (get) Token: 0x0600129A RID: 4762 RVA: 0x000490E0 File Offset: 0x000472E0
public virtual string TwoLetterISOLanguageName
{
get
{
if (!this.constructed)
{
this.Construct();
}
return this.iso2lang;
}
}
/// <summary>Gets a value indicating whether the current <see cref="T:System.Globalization.CultureInfo" /> uses the user-selected culture settings.</summary>
/// <returns>true if the current <see cref="T:System.Globalization.CultureInfo" /> uses the user-selected culture settings; otherwise, false.</returns>
// Token: 0x1700031D RID: 797
// (get) Token: 0x0600129B RID: 4763 RVA: 0x000490FC File Offset: 0x000472FC
public bool UseUserOverride
{
get
{
return this.m_useUserOverride;
}
}
// Token: 0x1700031E RID: 798
// (get) Token: 0x0600129C RID: 4764 RVA: 0x00049104 File Offset: 0x00047304
internal string IcuName
{
get
{
if (!this.constructed)
{
this.Construct();
}
return this.icu_name;
}
}
/// <summary>Refreshes cached culture-related information.</summary>
/// <PermissionSet>
/// <IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="UnmanagedCode" />
/// </PermissionSet>
// Token: 0x0600129D RID: 4765 RVA: 0x00049120 File Offset: 0x00047320
public void ClearCachedData()
{
Thread.CurrentThread.CurrentCulture = null;
Thread.CurrentThread.CurrentUICulture = null;
}
/// <summary>Creates a copy of the current <see cref="T:System.Globalization.CultureInfo" />.</summary>
/// <returns>A copy of the current <see cref="T:System.Globalization.CultureInfo" />.</returns>
// Token: 0x0600129E RID: 4766 RVA: 0x00049138 File Offset: 0x00047338
public virtual object Clone()
{
if (!this.constructed)
{
this.Construct();
}
CultureInfo cultureInfo = (CultureInfo)base.MemberwiseClone();
cultureInfo.m_isReadOnly = false;
cultureInfo.cached_serialized_form = null;
if (!this.IsNeutralCulture)
{
cultureInfo.NumberFormat = (NumberFormatInfo)this.NumberFormat.Clone();
cultureInfo.DateTimeFormat = (DateTimeFormatInfo)this.DateTimeFormat.Clone();
}
return cultureInfo;
}
/// <summary>Determines whether the specified object is the same culture as the current <see cref="T:System.Globalization.CultureInfo" />.</summary>
/// <returns>true if <paramref name="value" /> is the same culture as the current <see cref="T:System.Globalization.CultureInfo" />; otherwise, false.</returns>
/// <param name="value">The object to compare with the current <see cref="T:System.Globalization.CultureInfo" />. </param>
// Token: 0x0600129F RID: 4767 RVA: 0x000491A8 File Offset: 0x000473A8
public override bool Equals(object value)
{
CultureInfo cultureInfo = value as CultureInfo;
return cultureInfo != null && cultureInfo.cultureID == this.cultureID;
}
/// <summary>Gets the list of supported cultures filtered by the specified <see cref="T:System.Globalization.CultureTypes" /> parameter.</summary>
/// <returns>An array of type <see cref="T:System.Globalization.CultureInfo" /> that contains the cultures specified by the <paramref name="types" /> parameter. The array of cultures is unsorted.</returns>
/// <param name="types">A bitwise combination of <see cref="T:System.Globalization.CultureTypes" /> values that filter the cultures to retrieve. </param>
/// <exception cref="T:System.ArgumentOutOfRangeException">
/// <paramref name="types" /> specifies an invalid combination of <see cref="T:System.Globalization.CultureTypes" /> values.</exception>
/// <PermissionSet>
/// <IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="UnmanagedCode" />
/// </PermissionSet>
// Token: 0x060012A0 RID: 4768 RVA: 0x000491D4 File Offset: 0x000473D4
public static CultureInfo[] GetCultures(CultureTypes types)
{
bool flag = (types & CultureTypes.NeutralCultures) != (CultureTypes)0;
bool flag2 = (types & CultureTypes.SpecificCultures) != (CultureTypes)0;
bool flag3 = (types & CultureTypes.InstalledWin32Cultures) != (CultureTypes)0;
CultureInfo[] array = CultureInfo.internal_get_cultures(flag, flag2, flag3);
if (flag && array.Length > 0 && array[0] == null)
{
array[0] = (CultureInfo)CultureInfo.InvariantCulture.Clone();
}
return array;
}
/// <summary>Serves as a hash function for the current <see cref="T:System.Globalization.CultureInfo" />, suitable for hashing algorithms and data structures, such as a hash table.</summary>
/// <returns>A hash code for the current <see cref="T:System.Globalization.CultureInfo" />.</returns>
// Token: 0x060012A1 RID: 4769 RVA: 0x00049234 File Offset: 0x00047434
public override int GetHashCode()
{
return this.cultureID;
}
/// <summary>Returns a read-only wrapper around the specified <see cref="T:System.Globalization.CultureInfo" />.</summary>
/// <returns>A read-only <see cref="T:System.Globalization.CultureInfo" /> wrapper around <paramref name="ci" />.</returns>
/// <param name="ci">The <see cref="T:System.Globalization.CultureInfo" /> to wrap. </param>
/// <exception cref="T:System.ArgumentNullException">
/// <paramref name="ci" /> is null. </exception>
// Token: 0x060012A2 RID: 4770 RVA: 0x0004923C File Offset: 0x0004743C
public static CultureInfo ReadOnly(CultureInfo ci)
{
if (ci == null)
{
throw new ArgumentNullException("ci");
}
if (ci.m_isReadOnly)
{
return ci;
}
CultureInfo cultureInfo = (CultureInfo)ci.Clone();
cultureInfo.m_isReadOnly = true;
if (cultureInfo.numInfo != null)
{
cultureInfo.numInfo = NumberFormatInfo.ReadOnly(cultureInfo.numInfo);
}
if (cultureInfo.dateTimeInfo != null)
{
cultureInfo.dateTimeInfo = DateTimeFormatInfo.ReadOnly(cultureInfo.dateTimeInfo);
}
if (cultureInfo.textInfo != null)
{
cultureInfo.textInfo = TextInfo.ReadOnly(cultureInfo.textInfo);
}
return cultureInfo;
}
/// <summary>Returns a string containing the name of the current <see cref="T:System.Globalization.CultureInfo" /> in the format "&lt;languagecode2&gt;-&lt;country/regioncode2&gt;".</summary>
/// <returns>A string containing the name of the current <see cref="T:System.Globalization.CultureInfo" />.</returns>
// Token: 0x060012A3 RID: 4771 RVA: 0x000492E4 File Offset: 0x000474E4
public override string ToString()
{
return this.m_name;
}
/// <summary>Gets the <see cref="T:System.Globalization.CompareInfo" /> that defines how to compare strings for the culture.</summary>
/// <returns>The <see cref="T:System.Globalization.CompareInfo" /> that defines how to compare strings for the culture.</returns>
/// <PermissionSet>
/// <IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="UnmanagedCode" />
/// </PermissionSet>
// Token: 0x1700031F RID: 799
// (get) Token: 0x060012A4 RID: 4772 RVA: 0x000492EC File Offset: 0x000474EC
public virtual CompareInfo CompareInfo
{
get
{
if (this.compareInfo == null)
{
if (!this.constructed)
{
this.Construct();
}
lock (this)
{
if (this.compareInfo == null)
{
this.compareInfo = new CompareInfo(this);
}
}
}
return this.compareInfo;
}
}
// Token: 0x060012A5 RID: 4773 RVA: 0x0004936C File Offset: 0x0004756C
internal static bool IsIDNeutralCulture(int lcid)
{
bool flag;
if (!CultureInfo.internal_is_lcid_neutral(lcid, out flag))
{
throw new ArgumentException(string.Format("Culture id 0x{:x4} is not supported.", lcid));
}
return flag;
}
/// <summary>Gets a value indicating whether the current <see cref="T:System.Globalization.CultureInfo" /> represents a neutral culture.</summary>
/// <returns>true if the current <see cref="T:System.Globalization.CultureInfo" /> represents a neutral culture; otherwise, false.</returns>
// Token: 0x17000320 RID: 800
// (get) Token: 0x060012A6 RID: 4774 RVA: 0x000493A0 File Offset: 0x000475A0
public virtual bool IsNeutralCulture
{
get
{
if (!this.constructed)
{
this.Construct();
}
return this.cultureID != 127 && ((this.cultureID & 65280) == 0 || this.specific_lcid == 0);
}
}
// Token: 0x060012A7 RID: 4775 RVA: 0x000493E0 File Offset: 0x000475E0
internal void CheckNeutral()
{
if (this.IsNeutralCulture)
{
throw new NotSupportedException("Culture \"" + this.m_name + "\" is a neutral culture. It can not be used in formatting and parsing and therefore cannot be set as the thread's current culture.");
}
}
/// <summary>Gets or sets a <see cref="T:System.Globalization.NumberFormatInfo" /> that defines the culturally appropriate format of displaying numbers, currency, and percentage.</summary>
/// <returns>A <see cref="T:System.Globalization.NumberFormatInfo" /> that defines the culturally appropriate format of displaying numbers, currency, and percentage.</returns>
/// <exception cref="T:System.ArgumentNullException">The property is set to null. </exception>
/// <exception cref="T:System.NotSupportedException">The <see cref="T:System.Globalization.CultureInfo" /> is for a neutral culture. </exception>
/// <exception cref="T:System.InvalidOperationException">The <see cref="P:System.Globalization.CultureInfo.NumberFormat" /> property or any of the <see cref="T:System.Globalization.NumberFormatInfo" /> properties is set, and the <see cref="T:System.Globalization.CultureInfo" /> is read-only. </exception>
// Token: 0x17000321 RID: 801
// (get) Token: 0x060012A8 RID: 4776 RVA: 0x00049414 File Offset: 0x00047614
// (set) Token: 0x060012A9 RID: 4777 RVA: 0x000494A4 File Offset: 0x000476A4
public virtual NumberFormatInfo NumberFormat
{
get
{
if (!this.constructed)
{
this.Construct();
}
this.CheckNeutral();
if (this.numInfo == null)
{
lock (this)
{
if (this.numInfo == null)
{
this.numInfo = new NumberFormatInfo(this.m_isReadOnly);
this.construct_number_format();
}
}
}
return this.numInfo;
}
set
{
if (!this.constructed)
{
this.Construct();
}
if (this.m_isReadOnly)
{
throw new InvalidOperationException(CultureInfo.MSG_READONLY);
}
if (value == null)
{
throw new ArgumentNullException("NumberFormat");
}
this.numInfo = value;
}
}
/// <summary>Gets or sets a <see cref="T:System.Globalization.DateTimeFormatInfo" /> that defines the culturally appropriate format of displaying dates and times.</summary>
/// <returns>A <see cref="T:System.Globalization.DateTimeFormatInfo" /> that defines the culturally appropriate format of displaying dates and times.</returns>
/// <exception cref="T:System.ArgumentNullException">The property is set to null. </exception>
/// <exception cref="T:System.NotSupportedException">The <see cref="T:System.Globalization.CultureInfo" /> is for a neutral culture. </exception>
/// <exception cref="T:System.InvalidOperationException">The <see cref="P:System.Globalization.CultureInfo.DateTimeFormat" /> property or any of the <see cref="T:System.Globalization.DateTimeFormatInfo" /> properties is set, and the <see cref="T:System.Globalization.CultureInfo" /> is read-only. </exception>
// Token: 0x17000322 RID: 802
// (get) Token: 0x060012AA RID: 4778 RVA: 0x000494F4 File Offset: 0x000476F4
// (set) Token: 0x060012AB RID: 4779 RVA: 0x000495A4 File Offset: 0x000477A4
public virtual DateTimeFormatInfo DateTimeFormat
{
get
{
if (!this.constructed)
{
this.Construct();
}
this.CheckNeutral();
if (this.dateTimeInfo == null)
{
lock (this)
{
if (this.dateTimeInfo == null)
{
this.dateTimeInfo = new DateTimeFormatInfo(this.m_isReadOnly);
this.construct_datetime_format();
if (this.optional_calendars != null)
{
this.dateTimeInfo.Calendar = this.optional_calendars[0];
}
}
}
}
return this.dateTimeInfo;
}
set
{
if (!this.constructed)
{
this.Construct();
}
if (this.m_isReadOnly)
{
throw new InvalidOperationException(CultureInfo.MSG_READONLY);
}
if (value == null)
{
throw new ArgumentNullException("DateTimeFormat");
}
this.dateTimeInfo = value;
}
}
/// <summary>Gets the culture name in the format "&lt;languagefull&gt; (&lt;country/regionfull&gt;)" in the language of the localized version of .NET Framework.</summary>
/// <returns>The culture name in the format "&lt;languagefull&gt; (&lt;country/regionfull&gt;)" in the language of the localized version of .NET Framework, where &lt;languagefull&gt; is the full name of the language and &lt;country/regionfull&gt; is the full name of the country/region.</returns>
// Token: 0x17000323 RID: 803
// (get) Token: 0x060012AC RID: 4780 RVA: 0x000495F4 File Offset: 0x000477F4
public virtual string DisplayName
{
get
{
if (!this.constructed)
{
this.Construct();
}
return this.displayname;
}
}
/// <summary>Gets the culture name in the format "&lt;languagefull&gt; (&lt;country/regionfull&gt;)" in English.</summary>
/// <returns>The culture name in the format "&lt;languagefull&gt; (&lt;country/regionfull&gt;)" in English, where &lt;languagefull&gt; is the full name of the language and &lt;country/regionfull&gt; is the full name of the country/region.</returns>
// Token: 0x17000324 RID: 804
// (get) Token: 0x060012AD RID: 4781 RVA: 0x00049610 File Offset: 0x00047810
public virtual string EnglishName
{
get
{
if (!this.constructed)
{
this.Construct();
}
return this.englishname;
}
}
/// <summary>Gets the <see cref="T:System.Globalization.CultureInfo" /> that represents the culture installed with the operating system.</summary>
/// <returns>The <see cref="T:System.Globalization.CultureInfo" /> that represents the culture installed with the operating system.</returns>
/// <PermissionSet>
/// <IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="UnmanagedCode" />
/// </PermissionSet>
// Token: 0x17000325 RID: 805
// (get) Token: 0x060012AE RID: 4782 RVA: 0x0004962C File Offset: 0x0004782C
public static CultureInfo InstalledUICulture
{
get
{
return CultureInfo.GetCultureInfo(CultureInfo.BootstrapCultureID);
}
}
/// <summary>Gets a value indicating whether the current <see cref="T:System.Globalization.CultureInfo" /> is read-only.</summary>
/// <returns>true if the current <see cref="T:System.Globalization.CultureInfo" /> is read-only; otherwise, false. The default is false.</returns>
// Token: 0x17000326 RID: 806
// (get) Token: 0x060012AF RID: 4783 RVA: 0x00049638 File Offset: 0x00047838
public bool IsReadOnly
{
get
{
return this.m_isReadOnly;
}
}
/// <summary>Gets an object that defines how to format the specified type.</summary>
/// <returns>The value of the <see cref="P:System.Globalization.CultureInfo.NumberFormat" /> property, which is a <see cref="T:System.Globalization.NumberFormatInfo" /> containing the default number format information for the current <see cref="T:System.Globalization.CultureInfo" />, if <paramref name="formatType" /> is the <see cref="T:System.Type" /> object for the <see cref="T:System.Globalization.NumberFormatInfo" /> class.-or- The value of the <see cref="P:System.Globalization.CultureInfo.DateTimeFormat" /> property, which is a <see cref="T:System.Globalization.DateTimeFormatInfo" /> containing the default date and time format information for the current <see cref="T:System.Globalization.CultureInfo" />, if <paramref name="formatType" /> is the <see cref="T:System.Type" /> object for the <see cref="T:System.Globalization.DateTimeFormatInfo" /> class.-or- null, if <paramref name="formatType" /> is any other object.</returns>
/// <param name="formatType">The <see cref="T:System.Type" /> for which to get a formatting object. This method only supports the <see cref="T:System.Globalization.NumberFormatInfo" /> and <see cref="T:System.Globalization.DateTimeFormatInfo" /> types. </param>
// Token: 0x060012B0 RID: 4784 RVA: 0x00049640 File Offset: 0x00047840
public virtual object GetFormat(Type formatType)
{
object obj = null;
if (formatType == typeof(NumberFormatInfo))
{
obj = this.NumberFormat;
}
else if (formatType == typeof(DateTimeFormatInfo))
{
obj = this.DateTimeFormat;
}
return obj;
}
// Token: 0x060012B1 RID: 4785 RVA: 0x00049684 File Offset: 0x00047884
private void Construct()
{
this.construct_internal_locale_from_lcid(this.cultureID);
this.constructed = true;
}
// Token: 0x060012B2 RID: 4786 RVA: 0x0004969C File Offset: 0x0004789C
private bool ConstructInternalLocaleFromName(string locale)
{
string text = locale;
if (text != null)
{
if (CultureInfo.<>f__switch$map19 == null)
{
CultureInfo.<>f__switch$map19 = new Dictionary<string, int>(2)
{
{ "zh-hans", 0 },
{ "zh-hant", 1 }
};
}
int num;
if (CultureInfo.<>f__switch$map19.TryGetValue(text, out num))
{
if (num != 0)
{
if (num == 1)
{
locale = "zh-cht";
}
}
else
{
locale = "zh-chs";
}
}
}
return this.construct_internal_locale_from_name(locale);
}
// Token: 0x060012B3 RID: 4787 RVA: 0x0004972C File Offset: 0x0004792C
private bool ConstructInternalLocaleFromLcid(int lcid)
{
return this.construct_internal_locale_from_lcid(lcid);
}
// Token: 0x060012B4 RID: 4788 RVA: 0x00049740 File Offset: 0x00047940
private static bool ConstructInternalLocaleFromSpecificName(CultureInfo ci, string name)
{
return CultureInfo.construct_internal_locale_from_specific_name(ci, name);
}
// Token: 0x060012B5 RID: 4789 RVA: 0x00049754 File Offset: 0x00047954
private static bool ConstructInternalLocaleFromCurrentLocale(CultureInfo ci)
{
return CultureInfo.construct_internal_locale_from_current_locale(ci);
}
// Token: 0x060012B6 RID: 4790
[MethodImpl(MethodImplOptions.InternalCall)]
private extern bool construct_internal_locale_from_lcid(int lcid);
// Token: 0x060012B7 RID: 4791
[MethodImpl(MethodImplOptions.InternalCall)]
private extern bool construct_internal_locale_from_name(string name);
// Token: 0x060012B8 RID: 4792
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern bool construct_internal_locale_from_specific_name(CultureInfo ci, string name);
// Token: 0x060012B9 RID: 4793
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern bool construct_internal_locale_from_current_locale(CultureInfo ci);
// Token: 0x060012BA RID: 4794
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern CultureInfo[] internal_get_cultures(bool neutral, bool specific, bool installed);
// Token: 0x060012BB RID: 4795
[MethodImpl(MethodImplOptions.InternalCall)]
private extern void construct_datetime_format();
// Token: 0x060012BC RID: 4796
[MethodImpl(MethodImplOptions.InternalCall)]
private extern void construct_number_format();
// Token: 0x060012BD RID: 4797
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern bool internal_is_lcid_neutral(int lcid, out bool is_neutral);
// Token: 0x060012BE RID: 4798 RVA: 0x00049764 File Offset: 0x00047964
private void ConstructInvariant(bool read_only)
{
this.cultureID = 127;
this.numInfo = NumberFormatInfo.InvariantInfo;
this.dateTimeInfo = DateTimeFormatInfo.InvariantInfo;
if (!read_only)
{
this.numInfo = (NumberFormatInfo)this.numInfo.Clone();
this.dateTimeInfo = (DateTimeFormatInfo)this.dateTimeInfo.Clone();
}
this.textInfo = this.CreateTextInfo(read_only);
this.m_name = string.Empty;
this.displayname = (this.englishname = (this.nativename = "Invariant Language (Invariant Country)"));
this.iso3lang = "IVL";
this.iso2lang = "iv";
this.icu_name = "en_US_POSIX";
this.win3lang = "IVL";
}
// Token: 0x060012BF RID: 4799 RVA: 0x00049830 File Offset: 0x00047A30
private TextInfo CreateTextInfo(bool readOnly)
{
return new TextInfo(this, this.cultureID, this.textinfo_data, readOnly);
}
// Token: 0x060012C0 RID: 4800 RVA: 0x00049848 File Offset: 0x00047A48
private static void insert_into_shared_tables(CultureInfo c)
{
if (CultureInfo.shared_by_number == null)
{
CultureInfo.shared_by_number = new Hashtable();
CultureInfo.shared_by_name = new Hashtable();
}
CultureInfo.shared_by_number[c.cultureID] = c;
CultureInfo.shared_by_name[c.m_name] = c;
}
/// <summary>Retrieves a cached, read-only instance of a culture using the specified culture identifier.</summary>
/// <returns>A read-only <see cref="T:System.Globalization.CultureInfo" /> object.</returns>
/// <param name="culture">A culture identifier.</param>
/// <exception cref="T:System.ArgumentOutOfRangeException">
/// <paramref name="culture" /> is less than zero.</exception>
/// <exception cref="T:System.ArgumentException">
/// <paramref name="culture" /> specifies a culture that is not supported.</exception>
// Token: 0x060012C1 RID: 4801 RVA: 0x0004989C File Offset: 0x00047A9C
public static CultureInfo GetCultureInfo(int culture)
{
object obj = CultureInfo.shared_table_lock;
CultureInfo cultureInfo2;
lock (obj)
{
CultureInfo cultureInfo;
if (CultureInfo.shared_by_number != null)
{
cultureInfo = CultureInfo.shared_by_number[culture] as CultureInfo;
if (cultureInfo != null)
{
return cultureInfo;
}
}
cultureInfo = new CultureInfo(culture, false, true);
CultureInfo.insert_into_shared_tables(cultureInfo);
cultureInfo2 = cultureInfo;
}
return cultureInfo2;
}
/// <summary>Retrieves a cached, read-only instance of a culture using the specified culture name. </summary>
/// <returns>A read-only <see cref="T:System.Globalization.CultureInfo" /> object.</returns>
/// <param name="name">The name of a culture.</param>
/// <exception cref="T:System.ArgumentNullException">
/// <paramref name="name" /> is null.</exception>
/// <exception cref="T:System.ArgumentException">
/// <paramref name="name" /> specifies a culture that is not supported.</exception>
// Token: 0x060012C2 RID: 4802 RVA: 0x00049924 File Offset: 0x00047B24
public static CultureInfo GetCultureInfo(string name)
{
if (name == null)
{
throw new ArgumentNullException("name");
}
object obj = CultureInfo.shared_table_lock;
CultureInfo cultureInfo2;
lock (obj)
{
CultureInfo cultureInfo;
if (CultureInfo.shared_by_name != null)
{
cultureInfo = CultureInfo.shared_by_name[name] as CultureInfo;
if (cultureInfo != null)
{
return cultureInfo;
}
}
cultureInfo = new CultureInfo(name, false, true);
CultureInfo.insert_into_shared_tables(cultureInfo);
cultureInfo2 = cultureInfo;
}
return cultureInfo2;
}
/// <summary>Retrieves a cached, read-only instance of a culture. Parameters specify a culture that is initialized with the <see cref="T:System.Globalization.TextInfo" /> and <see cref="T:System.Globalization.CompareInfo" /> objects specified by another culture.</summary>
/// <returns>A read-only <see cref="T:System.Globalization.CultureInfo" /> object.</returns>
/// <param name="name">The name of a culture.</param>
/// <param name="altName">The name of a culture that supplies the <see cref="T:System.Globalization.TextInfo" /> and <see cref="T:System.Globalization.CompareInfo" /> objects used to initialize <paramref name="name" />.</param>
/// <exception cref="T:System.ArgumentNullException">
/// <paramref name="name" /> or <paramref name="altName" /> is null.</exception>
/// <exception cref="T:System.ArgumentException">
/// <paramref name="name" /> or <paramref name="altName" /> specifies a culture that is not supported.</exception>
// Token: 0x060012C3 RID: 4803 RVA: 0x000499B8 File Offset: 0x00047BB8
[MonoTODO("Currently it ignores the altName parameter")]
public static CultureInfo GetCultureInfo(string name, string altName)
{
if (name == null)
{
throw new ArgumentNullException("null");
}
if (altName == null)
{
throw new ArgumentNullException("null");
}
return CultureInfo.GetCultureInfo(name);
}
/// <summary>Deprecated. Retrieves a read-only <see cref="T:System.Globalization.CultureInfo" /> object having linguistic characteristics that are identified by the specified RFC 4646 language tag. </summary>
/// <returns>A read-only <see cref="T:System.Globalization.CultureInfo" /> object.</returns>
/// <param name="name">The name of a language as specified by the RFC 4646 standard.</param>
/// <exception cref="T:System.ArgumentNullException">
/// <paramref name="name" /> is null.</exception>
/// <exception cref="T:System.ArgumentException">
/// <paramref name="name" /> does not correspond to a supported culture.</exception>
// Token: 0x060012C4 RID: 4804 RVA: 0x000499F0 File Offset: 0x00047BF0
public static CultureInfo GetCultureInfoByIetfLanguageTag(string name)
{
if (name != null)
{
if (CultureInfo.<>f__switch$map1A == null)
{
CultureInfo.<>f__switch$map1A = new Dictionary<string, int>(2)
{
{ "zh-Hans", 0 },
{ "zh-Hant", 1 }
};
}
int num;
if (CultureInfo.<>f__switch$map1A.TryGetValue(name, out num))
{
if (num == 0)
{
return CultureInfo.GetCultureInfo("zh-CHS");
}
if (num == 1)
{
return CultureInfo.GetCultureInfo("zh-CHT");
}
}
}
return CultureInfo.GetCultureInfo(name);
}
// Token: 0x060012C5 RID: 4805 RVA: 0x00049A74 File Offset: 0x00047C74
internal static CultureInfo CreateCulture(string name, bool reference)
{
bool flag = name.Length == 0;
bool flag2;
bool flag3;
if (reference)
{
flag2 = !flag;
flag3 = false;
}
else
{
flag3 = false;
flag2 = !flag;
}
return new CultureInfo(name, flag2, flag3);
}
// Token: 0x060012C6 RID: 4806 RVA: 0x00049AC0 File Offset: 0x00047CC0
internal unsafe void ConstructCalendars()
{
if (this.calendar_data == null)
{
this.optional_calendars = new Calendar[]
{
new GregorianCalendar(GregorianCalendarTypes.Localized)
};
return;
}
this.optional_calendars = new Calendar[5];
for (int i = 0; i < 5; i++)
{
int num = this.calendar_data[i];
Calendar calendar;
switch (num >> 24)
{
case 0:
{
GregorianCalendarTypes gregorianCalendarTypes = (GregorianCalendarTypes)(num & 16777215);
calendar = new GregorianCalendar(gregorianCalendarTypes);
break;
}
case 1:
calendar = new HijriCalendar();
break;
case 2:
calendar = new ThaiBuddhistCalendar();
break;
default:
throw new Exception("invalid calendar type: " + num);
}
this.optional_calendars[i] = calendar;
}
}
// Token: 0x040004D6 RID: 1238
private const int NumOptionalCalendars = 5;
// Token: 0x040004D7 RID: 1239
private const int GregorianTypeMask = 16777215;
// Token: 0x040004D8 RID: 1240
private const int CalendarTypeBits = 24;
// Token: 0x040004D9 RID: 1241
private const int InvariantCultureId = 127;
// Token: 0x040004DA RID: 1242
private static volatile CultureInfo invariant_culture_info = new CultureInfo(127, false, true);
// Token: 0x040004DB RID: 1243
private static object shared_table_lock = new object();
// Token: 0x040004DC RID: 1244
internal static int BootstrapCultureID;
// Token: 0x040004DD RID: 1245
private bool m_isReadOnly;
// Token: 0x040004DE RID: 1246
private int cultureID;
// Token: 0x040004DF RID: 1247
[NonSerialized]
private int parent_lcid;
// Token: 0x040004E0 RID: 1248
[NonSerialized]
private int specific_lcid;
// Token: 0x040004E1 RID: 1249
[NonSerialized]
private int datetime_index;
// Token: 0x040004E2 RID: 1250
[NonSerialized]
private int number_index;
// Token: 0x040004E3 RID: 1251
private bool m_useUserOverride;
// Token: 0x040004E4 RID: 1252
[NonSerialized]
private volatile NumberFormatInfo numInfo;
// Token: 0x040004E5 RID: 1253
private volatile DateTimeFormatInfo dateTimeInfo;
// Token: 0x040004E6 RID: 1254
private volatile TextInfo textInfo;
// Token: 0x040004E7 RID: 1255
private string m_name;
// Token: 0x040004E8 RID: 1256
[NonSerialized]
private string displayname;
// Token: 0x040004E9 RID: 1257
[NonSerialized]
private string englishname;
// Token: 0x040004EA RID: 1258
[NonSerialized]
private string nativename;
// Token: 0x040004EB RID: 1259
[NonSerialized]
private string iso3lang;
// Token: 0x040004EC RID: 1260
[NonSerialized]
private string iso2lang;
// Token: 0x040004ED RID: 1261
[NonSerialized]
private string icu_name;
// Token: 0x040004EE RID: 1262
[NonSerialized]
private string win3lang;
// Token: 0x040004EF RID: 1263
[NonSerialized]
private string territory;
// Token: 0x040004F0 RID: 1264
private volatile CompareInfo compareInfo;
// Token: 0x040004F1 RID: 1265
[NonSerialized]
private unsafe readonly int* calendar_data;
// Token: 0x040004F2 RID: 1266
[NonSerialized]
private unsafe readonly void* textinfo_data;
// Token: 0x040004F3 RID: 1267
[NonSerialized]
private Calendar[] optional_calendars;
// Token: 0x040004F4 RID: 1268
[NonSerialized]
private CultureInfo parent_culture;
// Token: 0x040004F5 RID: 1269
private int m_dataItem;
// Token: 0x040004F6 RID: 1270
private Calendar calendar;
// Token: 0x040004F7 RID: 1271
[NonSerialized]
private bool constructed;
// Token: 0x040004F8 RID: 1272
[NonSerialized]
internal byte[] cached_serialized_form;
// Token: 0x040004F9 RID: 1273
private static readonly string MSG_READONLY = "This instance is read only";
// Token: 0x040004FA RID: 1274
private static Hashtable shared_by_number;
// Token: 0x040004FB RID: 1275
private static Hashtable shared_by_name;
}
}