diff options
Diffstat (limited to 'src/mscorlib/src/System/Globalization/NumberFormatInfo.cs')
-rw-r--r-- | src/mscorlib/src/System/Globalization/NumberFormatInfo.cs | 542 |
1 files changed, 313 insertions, 229 deletions
diff --git a/src/mscorlib/src/System/Globalization/NumberFormatInfo.cs b/src/mscorlib/src/System/Globalization/NumberFormatInfo.cs index d95aac3d3d..c44c085a69 100644 --- a/src/mscorlib/src/System/Globalization/NumberFormatInfo.cs +++ b/src/mscorlib/src/System/Globalization/NumberFormatInfo.cs @@ -2,11 +2,13 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -namespace System.Globalization { - using System.Runtime.Serialization; - using System.Text; - using System; - using System.Diagnostics.Contracts; +using System; +using System.Diagnostics.Contracts; +using System.Runtime.Serialization; +using System.Text; + +namespace System.Globalization +{ // // Property Default Description // PositiveSign '+' Character used to indicate positive values. @@ -40,19 +42,19 @@ namespace System.Globalization { // [Serializable] - sealed public partial class NumberFormatInfo : ICloneable, IFormatProvider + sealed public class NumberFormatInfo : IFormatProvider, ICloneable { // invariantInfo is constant irrespective of your current culture. - private static volatile NumberFormatInfo invariantInfo; + private static volatile NumberFormatInfo s_invariantInfo; // READTHIS READTHIS READTHIS // This class has an exact mapping onto a native structure defined in COMNumber.cpp // DO NOT UPDATE THIS WITHOUT UPDATING THAT STRUCTURE. IF YOU ADD BOOL, ADD THEM AT THE END. // ALSO MAKE SURE TO UPDATE mscorlib.h in the VM directory to check field offsets. // READTHIS READTHIS READTHIS - internal int[] numberGroupSizes = new int[] {3}; - internal int[] currencyGroupSizes = new int[] {3}; - internal int[] percentGroupSizes = new int[] {3}; + internal int[] numberGroupSizes = new int[] { 3 }; + internal int[] currencyGroupSizes = new int[] { 3 }; + internal int[] percentGroupSizes = new int[] { 3 }; internal String positiveSign = "+"; internal String negativeSign = "-"; internal String numberDecimalSeparator = "."; @@ -60,10 +62,6 @@ namespace System.Globalization { internal String currencyGroupSeparator = ","; internal String currencyDecimalSeparator = "."; internal String currencySymbol = "\x00a4"; // U+00a4 is the symbol for International Monetary Fund. - // The alternative currency symbol used in Win9x ANSI codepage, that can not roundtrip between ANSI and Unicode. - // Currently, only ja-JP and ko-KR has non-null values (which is U+005c, backslash) - // NOTE: The only legal values for this string are null and "\x005c" - internal String ansiCurrencySymbol = null; internal String nanSymbol = "NaN"; internal String positiveInfinitySymbol = "Infinity"; internal String negativeInfinitySymbol = "-Infinity"; @@ -72,14 +70,9 @@ namespace System.Globalization { internal String percentSymbol = "%"; internal String perMilleSymbol = "\u2030"; - [OptionalField(VersionAdded = 2)] - internal String[] nativeDigits = {"0", "1", "2", "3", "4", "5", "6", "7", "8", "9"}; - // an index which points to a record in Culture Data Table. - // We shouldn't be persisting dataItem (since its useless & we weren't using it), - // but since COMNumber.cpp uses it and since serialization isn't implimented, its stuck for now. - [OptionalField(VersionAdded = 1)] - internal int m_dataItem = 0; // NEVER USED, DO NOT USE THIS! (Serialized in Everett) + [OptionalField(VersionAdded = 2)] + internal String[] nativeDigits = { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9" }; internal int numberDecimalDigits = 2; internal int currencyDecimalDigits = 2; @@ -91,109 +84,100 @@ namespace System.Globalization { internal int percentDecimalDigits = 2; [OptionalField(VersionAdded = 2)] - internal int digitSubstitution = 1; // DigitShapes.None + internal int digitSubstitution = (int) DigitShapes.None; - internal bool isReadOnly=false; - // We shouldn't be persisting m_useUserOverride (since its useless & we weren't using it), - // but since COMNumber.cpp uses it and since serialization isn't implimented, its stuck for now. - [OptionalField(VersionAdded = 1)] - internal bool m_useUserOverride=false; // NEVER USED, DO NOT USE THIS! (Serialized in Everett) + internal bool isReadOnly = false; // Is this NumberFormatInfo for invariant culture? + [OptionalField(VersionAdded = 2)] - internal bool m_isInvariant=false; + internal bool m_isInvariant = false; - public NumberFormatInfo() : this(null) { + public NumberFormatInfo() : this(null) + { } -#region Serialization - // Check if NumberFormatInfo was not set up ambiguously for parsing as number and currency - // eg. if the NumberDecimalSeparator and the NumberGroupSeparator were the same. This check - // is solely for backwards compatibility / version tolerant serialization - [OptionalField(VersionAdded = 1)] - internal bool validForParseAsNumber = true; // NEVER USED, DO NOT USE THIS! (Serialized in Whidbey/Everett) - [OptionalField(VersionAdded = 1)] - internal bool validForParseAsCurrency = true; // NEVER USED, DO NOT USE THIS! (Serialized in Whidbey/Everett) - [OnSerializing] - private void OnSerializing(StreamingContext ctx) - { - } + private void OnSerializing(StreamingContext ctx) { } [OnDeserializing] - private void OnDeserializing(StreamingContext ctx) - { - } + private void OnDeserializing(StreamingContext ctx) { } [OnDeserialized] - private void OnDeserialized(StreamingContext ctx) - { - } -#endregion Serialization + private void OnDeserialized(StreamingContext ctx) { } - static private void VerifyDecimalSeparator(String decSep, String propertyName) { - if (decSep==null) { + private static void VerifyDecimalSeparator(String decSep, String propertyName) + { + if (decSep == null) + { throw new ArgumentNullException(propertyName, - Environment.GetResourceString("ArgumentNull_String")); + SR.ArgumentNull_String); } - if (decSep.Length==0) { - throw new ArgumentException(Environment.GetResourceString("Argument_EmptyDecString")); + if (decSep.Length == 0) + { + throw new ArgumentException(SR.Argument_EmptyDecString); } Contract.EndContractBlock(); - } - static private void VerifyGroupSeparator(String groupSep, String propertyName) { - if (groupSep==null) { + private static void VerifyGroupSeparator(String groupSep, String propertyName) + { + if (groupSep == null) + { throw new ArgumentNullException(propertyName, - Environment.GetResourceString("ArgumentNull_String")); + SR.ArgumentNull_String); } Contract.EndContractBlock(); } - static private void VerifyNativeDigits(String [] nativeDig, String propertyName) { - if (nativeDig==null) { - throw new ArgumentNullException(propertyName, - Environment.GetResourceString("ArgumentNull_Array")); + private static void VerifyNativeDigits(string [] nativeDig, string propertyName) + { + if (nativeDig == null) + { + throw new ArgumentNullException(propertyName, SR.ArgumentNull_Array); } if (nativeDig.Length != 10) { - throw new ArgumentException(Environment.GetResourceString("Argument_InvalidNativeDigitCount"), propertyName); + throw new ArgumentException(SR.Argument_InvalidNativeDigitCount, propertyName); } Contract.EndContractBlock(); - for(int i = 0; i < nativeDig.Length; i++) + for (int i = 0; i < nativeDig.Length; i++) { if (nativeDig[i] == null) { - throw new ArgumentNullException(propertyName, - Environment.GetResourceString("ArgumentNull_ArrayValue")); + throw new ArgumentNullException(propertyName, SR.ArgumentNull_ArrayValue); } - - if (nativeDig[i].Length != 1) { - if(nativeDig[i].Length != 2) { + if (nativeDig[i].Length != 1) + { + if (nativeDig[i].Length != 2) + { // Not 1 or 2 UTF-16 code points - throw new ArgumentException(Environment.GetResourceString("Argument_InvalidNativeDigitValue"), propertyName); - } else if(!char.IsSurrogatePair(nativeDig[i][0], nativeDig[i][1])) { + throw new ArgumentException(SR.Argument_InvalidNativeDigitValue, propertyName); + } + else if (!char.IsSurrogatePair(nativeDig[i][0], nativeDig[i][1])) + { // 2 UTF-6 code points, but not a surrogate pair - throw new ArgumentException(Environment.GetResourceString("Argument_InvalidNativeDigitValue"), propertyName); + throw new ArgumentException(SR.Argument_InvalidNativeDigitValue, propertyName); } } if (CharUnicodeInfo.GetDecimalDigitValue(nativeDig[i], 0) != i && - CharUnicodeInfo.GetUnicodeCategory(nativeDig[i], 0) != UnicodeCategory.PrivateUse) { + CharUnicodeInfo.GetUnicodeCategory(nativeDig[i], 0) != UnicodeCategory.PrivateUse) + { // Not the appropriate digit according to the Unicode data properties // (Digit 0 must be a 0, etc.). - throw new ArgumentException(Environment.GetResourceString("Argument_InvalidNativeDigitValue"), propertyName); + throw new ArgumentException(SR.Argument_InvalidNativeDigitValue, propertyName); } } } - static private void VerifyDigitSubstitution(DigitShapes digitSub, String propertyName) { - switch(digitSub) + private static void VerifyDigitSubstitution(DigitShapes digitSub, string propertyName) + { + switch (digitSub) { case DigitShapes.Context: case DigitShapes.None: @@ -202,12 +186,10 @@ namespace System.Globalization { break; default: - throw new ArgumentException(Environment.GetResourceString("Argument_InvalidDigitSubstitution"), propertyName); + throw new ArgumentException(SR.Argument_InvalidDigitSubstitution, propertyName); } } - // We aren't persisting dataItem any more (since its useless & we weren't using it), - // Ditto with m_useUserOverride. Don't use them, we use a local copy of everything. internal NumberFormatInfo(CultureData cultureData) { if (cultureData != null) @@ -225,9 +207,11 @@ namespace System.Globalization { } [Pure] - private void VerifyWritable() { - if (isReadOnly) { - throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_ReadOnly")); + private void VerifyWritable() + { + if (isReadOnly) + { + throw new InvalidOperationException(SR.InvalidOperation_ReadOnly); } Contract.EndContractBlock(); } @@ -237,41 +221,50 @@ namespace System.Globalization { // Used by FromString methods. // - public static NumberFormatInfo InvariantInfo { - get { - if (invariantInfo == null) { + public static NumberFormatInfo InvariantInfo + { + get + { + if (s_invariantInfo == null) + { // Lazy create the invariant info. This cannot be done in a .cctor because exceptions can // be thrown out of a .cctor stack that will need this. NumberFormatInfo nfi = new NumberFormatInfo(); nfi.m_isInvariant = true; - invariantInfo = ReadOnly(nfi); + s_invariantInfo = ReadOnly(nfi); } - return invariantInfo; + return s_invariantInfo; } } - - public static NumberFormatInfo GetInstance(IFormatProvider formatProvider) { + public static NumberFormatInfo GetInstance(IFormatProvider formatProvider) + { // Fast case for a regular CultureInfo NumberFormatInfo info; CultureInfo cultureProvider = formatProvider as CultureInfo; - if (cultureProvider != null && !cultureProvider.m_isInherited) { + if (cultureProvider != null && !cultureProvider._isInherited) + { info = cultureProvider.numInfo; - if (info != null) { + if (info != null) + { return info; } - else { + else + { return cultureProvider.NumberFormat; } } // Fast case for an NFI; info = formatProvider as NumberFormatInfo; - if (info != null) { + if (info != null) + { return info; } - if (formatProvider != null) { + if (formatProvider != null) + { info = formatProvider.GetFormat(typeof(NumberFormatInfo)) as NumberFormatInfo; - if (info != null) { + if (info != null) + { return info; } } @@ -280,22 +273,26 @@ namespace System.Globalization { - public Object Clone() { + public Object Clone() + { NumberFormatInfo n = (NumberFormatInfo)MemberwiseClone(); n.isReadOnly = false; return n; } - public int CurrencyDecimalDigits { + public int CurrencyDecimalDigits + { get { return currencyDecimalDigits; } - set { - if (value < 0 || value > 99) { + set + { + if (value < 0 || value > 99) + { throw new ArgumentOutOfRangeException( nameof(CurrencyDecimalDigits), String.Format( CultureInfo.CurrentCulture, - Environment.GetResourceString("ArgumentOutOfRange_Range"), + SR.ArgumentOutOfRange_Range, 0, 99)); } @@ -306,18 +303,22 @@ namespace System.Globalization { } - public String CurrencyDecimalSeparator { + public String CurrencyDecimalSeparator + { get { return currencyDecimalSeparator; } - set { + set + { VerifyWritable(); - VerifyDecimalSeparator(value, nameof(CurrencyDecimalSeparator)); + VerifyDecimalSeparator(value, "CurrencyDecimalSeparator"); currencyDecimalSeparator = value; } } - public bool IsReadOnly { - get { + public bool IsReadOnly + { + get + { return isReadOnly; } } @@ -328,7 +329,7 @@ namespace System.Globalization { // Every element in the groupSize array should be between 1 and 9 // excpet the last element could be zero. // - static internal void CheckGroupSize(String propName, int[] groupSize) + internal static void CheckGroupSize(String propName, int[] groupSize) { for (int i = 0; i < groupSize.Length; i++) { @@ -336,49 +337,56 @@ namespace System.Globalization { { if (i == groupSize.Length - 1 && groupSize[i] == 0) return; - throw new ArgumentException(Environment.GetResourceString("Argument_InvalidGroupSize"), propName); + throw new ArgumentException(SR.Argument_InvalidGroupSize, propName); } else if (groupSize[i] > 9) { - throw new ArgumentException(Environment.GetResourceString("Argument_InvalidGroupSize"), propName); + throw new ArgumentException(SR.Argument_InvalidGroupSize, propName); } } } - public int[] CurrencyGroupSizes { - get { + public int[] CurrencyGroupSizes + { + get + { return ((int[])currencyGroupSizes.Clone()); } - set { - if (value == null) { + set + { + if (value == null) + { throw new ArgumentNullException(nameof(CurrencyGroupSizes), - Environment.GetResourceString("ArgumentNull_Obj")); + SR.ArgumentNull_Obj); } Contract.EndContractBlock(); - VerifyWritable(); - + VerifyWritable(); + Int32[] inputSizes = (Int32[])value.Clone(); CheckGroupSize(nameof(CurrencyGroupSizes), inputSizes); currencyGroupSizes = inputSizes; } - } - public int[] NumberGroupSizes { - get { + public int[] NumberGroupSizes + { + get + { return ((int[])numberGroupSizes.Clone()); } - set { - if (value == null) { + set + { + if (value == null) + { throw new ArgumentNullException(nameof(NumberGroupSizes), - Environment.GetResourceString("ArgumentNull_Obj")); + SR.ArgumentNull_Obj); } Contract.EndContractBlock(); VerifyWritable(); - + Int32[] inputSizes = (Int32[])value.Clone(); CheckGroupSize(nameof(NumberGroupSizes), inputSizes); numberGroupSizes = inputSizes; @@ -386,28 +394,33 @@ namespace System.Globalization { } - public int[] PercentGroupSizes { - get { + public int[] PercentGroupSizes + { + get + { return ((int[])percentGroupSizes.Clone()); } - set { - if (value == null) { - throw new ArgumentNullException(nameof(PercentGroupSizes), - Environment.GetResourceString("ArgumentNull_Obj")); + set + { + if (value == null) + { + throw new ArgumentNullException("PercentGroupSizes", + SR.ArgumentNull_Obj); } Contract.EndContractBlock(); VerifyWritable(); Int32[] inputSizes = (Int32[])value.Clone(); - CheckGroupSize(nameof(PercentGroupSizes), inputSizes); + CheckGroupSize("PercentGroupSizes", inputSizes); percentGroupSizes = inputSizes; } - } - public String CurrencyGroupSeparator { + public String CurrencyGroupSeparator + { get { return currencyGroupSeparator; } - set { + set + { VerifyWritable(); VerifyGroupSeparator(value, nameof(CurrencyGroupSeparator)); currencyGroupSeparator = value; @@ -415,12 +428,15 @@ namespace System.Globalization { } - public String CurrencySymbol { + public String CurrencySymbol + { get { return currencySymbol; } - set { - if (value == null) { + set + { + if (value == null) + { throw new ArgumentNullException(nameof(CurrencySymbol), - Environment.GetResourceString("ArgumentNull_String")); + SR.ArgumentNull_String); } Contract.EndContractBlock(); VerifyWritable(); @@ -431,12 +447,16 @@ namespace System.Globalization { // Returns the current culture's NumberFormatInfo. Used by Parse methods. // - public static NumberFormatInfo CurrentInfo { - get { - System.Globalization.CultureInfo culture = System.Threading.Thread.CurrentThread.CurrentCulture; - if (!culture.m_isInherited) { + public static NumberFormatInfo CurrentInfo + { + get + { + System.Globalization.CultureInfo culture = CultureInfo.CurrentCulture; + if (!culture._isInherited) + { NumberFormatInfo info = culture.numInfo; - if (info != null) { + if (info != null) + { return info; } } @@ -445,14 +465,18 @@ namespace System.Globalization { } - public String NaNSymbol { - get { + public String NaNSymbol + { + get + { return nanSymbol; } - set { - if (value == null) { + set + { + if (value == null) + { throw new ArgumentNullException(nameof(NaNSymbol), - Environment.GetResourceString("ArgumentNull_String")); + SR.ArgumentNull_String); } Contract.EndContractBlock(); VerifyWritable(); @@ -462,15 +486,18 @@ namespace System.Globalization { - public int CurrencyNegativePattern { + public int CurrencyNegativePattern + { get { return currencyNegativePattern; } - set { - if (value < 0 || value > 15) { + set + { + if (value < 0 || value > 15) + { throw new ArgumentOutOfRangeException( nameof(CurrencyNegativePattern), String.Format( CultureInfo.CurrentCulture, - Environment.GetResourceString("ArgumentOutOfRange_Range"), + SR.ArgumentOutOfRange_Range, 0, 15)); } @@ -481,18 +508,21 @@ namespace System.Globalization { } - public int NumberNegativePattern { + public int NumberNegativePattern + { get { return numberNegativePattern; } - set { + set + { // // NOTENOTE: the range of value should correspond to negNumberFormats[] in vm\COMNumber.cpp. // - if (value < 0 || value > 4) { + if (value < 0 || value > 4) + { throw new ArgumentOutOfRangeException( nameof(NumberNegativePattern), String.Format( CultureInfo.CurrentCulture, - Environment.GetResourceString("ArgumentOutOfRange_Range"), + SR.ArgumentOutOfRange_Range, 0, 4)); } @@ -503,18 +533,21 @@ namespace System.Globalization { } - public int PercentPositivePattern { + public int PercentPositivePattern + { get { return percentPositivePattern; } - set { + set + { // // NOTENOTE: the range of value should correspond to posPercentFormats[] in vm\COMNumber.cpp. // - if (value < 0 || value > 3) { + if (value < 0 || value > 3) + { throw new ArgumentOutOfRangeException( nameof(PercentPositivePattern), String.Format( CultureInfo.CurrentCulture, - Environment.GetResourceString("ArgumentOutOfRange_Range"), + SR.ArgumentOutOfRange_Range, 0, 3)); } @@ -525,18 +558,21 @@ namespace System.Globalization { } - public int PercentNegativePattern { + public int PercentNegativePattern + { get { return percentNegativePattern; } - set { + set + { // // NOTENOTE: the range of value should correspond to posPercentFormats[] in vm\COMNumber.cpp. // - if (value < 0 || value > 11) { + if (value < 0 || value > 11) + { throw new ArgumentOutOfRangeException( nameof(PercentNegativePattern), String.Format( CultureInfo.CurrentCulture, - Environment.GetResourceString("ArgumentOutOfRange_Range"), + SR.ArgumentOutOfRange_Range, 0, 11)); } @@ -547,14 +583,18 @@ namespace System.Globalization { } - public String NegativeInfinitySymbol { - get { + public String NegativeInfinitySymbol + { + get + { return negativeInfinitySymbol; } - set { - if (value == null) { + set + { + if (value == null) + { throw new ArgumentNullException(nameof(NegativeInfinitySymbol), - Environment.GetResourceString("ArgumentNull_String")); + SR.ArgumentNull_String); } Contract.EndContractBlock(); VerifyWritable(); @@ -563,12 +603,15 @@ namespace System.Globalization { } - public String NegativeSign { + public String NegativeSign + { get { return negativeSign; } - set { - if (value == null) { + set + { + if (value == null) + { throw new ArgumentNullException(nameof(NegativeSign), - Environment.GetResourceString("ArgumentNull_String")); + SR.ArgumentNull_String); } Contract.EndContractBlock(); VerifyWritable(); @@ -577,15 +620,18 @@ namespace System.Globalization { } - public int NumberDecimalDigits { + public int NumberDecimalDigits + { get { return numberDecimalDigits; } - set { - if (value < 0 || value > 99) { + set + { + if (value < 0 || value > 99) + { throw new ArgumentOutOfRangeException( nameof(NumberDecimalDigits), String.Format( CultureInfo.CurrentCulture, - Environment.GetResourceString("ArgumentOutOfRange_Range"), + SR.ArgumentOutOfRange_Range, 0, 99)); } @@ -596,9 +642,11 @@ namespace System.Globalization { } - public String NumberDecimalSeparator { + public String NumberDecimalSeparator + { get { return numberDecimalSeparator; } - set { + set + { VerifyWritable(); VerifyDecimalSeparator(value, nameof(NumberDecimalSeparator)); numberDecimalSeparator = value; @@ -606,9 +654,11 @@ namespace System.Globalization { } - public String NumberGroupSeparator { + public String NumberGroupSeparator + { get { return numberGroupSeparator; } - set { + set + { VerifyWritable(); VerifyGroupSeparator(value, nameof(NumberGroupSeparator)); numberGroupSeparator = value; @@ -616,15 +666,18 @@ namespace System.Globalization { } - public int CurrencyPositivePattern { + public int CurrencyPositivePattern + { get { return currencyPositivePattern; } - set { - if (value < 0 || value > 3) { + set + { + if (value < 0 || value > 3) + { throw new ArgumentOutOfRangeException( nameof(CurrencyPositivePattern), String.Format( CultureInfo.CurrentCulture, - Environment.GetResourceString("ArgumentOutOfRange_Range"), + SR.ArgumentOutOfRange_Range, 0, 3)); } @@ -635,14 +688,18 @@ namespace System.Globalization { } - public String PositiveInfinitySymbol { - get { + public String PositiveInfinitySymbol + { + get + { return positiveInfinitySymbol; } - set { - if (value == null) { + set + { + if (value == null) + { throw new ArgumentNullException(nameof(PositiveInfinitySymbol), - Environment.GetResourceString("ArgumentNull_String")); + SR.ArgumentNull_String); } Contract.EndContractBlock(); VerifyWritable(); @@ -651,12 +708,15 @@ namespace System.Globalization { } - public String PositiveSign { + public String PositiveSign + { get { return positiveSign; } - set { - if (value == null) { + set + { + if (value == null) + { throw new ArgumentNullException(nameof(PositiveSign), - Environment.GetResourceString("ArgumentNull_String")); + SR.ArgumentNull_String); } Contract.EndContractBlock(); VerifyWritable(); @@ -665,15 +725,18 @@ namespace System.Globalization { } - public int PercentDecimalDigits { + public int PercentDecimalDigits + { get { return percentDecimalDigits; } - set { - if (value < 0 || value > 99) { + set + { + if (value < 0 || value > 99) + { throw new ArgumentOutOfRangeException( nameof(PercentDecimalDigits), String.Format( CultureInfo.CurrentCulture, - Environment.GetResourceString("ArgumentOutOfRange_Range"), + SR.ArgumentOutOfRange_Range, 0, 99)); } @@ -684,9 +747,11 @@ namespace System.Globalization { } - public String PercentDecimalSeparator { + public String PercentDecimalSeparator + { get { return percentDecimalSeparator; } - set { + set + { VerifyWritable(); VerifyDecimalSeparator(value, nameof(PercentDecimalSeparator)); percentDecimalSeparator = value; @@ -694,9 +759,11 @@ namespace System.Globalization { } - public String PercentGroupSeparator { + public String PercentGroupSeparator + { get { return percentGroupSeparator; } - set { + set + { VerifyWritable(); VerifyGroupSeparator(value, nameof(PercentGroupSeparator)); percentGroupSeparator = value; @@ -704,14 +771,18 @@ namespace System.Globalization { } - public String PercentSymbol { - get { + public String PercentSymbol + { + get + { return percentSymbol; } - set { - if (value == null) { + set + { + if (value == null) + { throw new ArgumentNullException(nameof(PercentSymbol), - Environment.GetResourceString("ArgumentNull_String")); + SR.ArgumentNull_String); } Contract.EndContractBlock(); VerifyWritable(); @@ -720,12 +791,15 @@ namespace System.Globalization { } - public String PerMilleSymbol { + public String PerMilleSymbol + { get { return perMilleSymbol; } - set { - if (value == null) { + set + { + if (value == null) + { throw new ArgumentNullException(nameof(PerMilleSymbol), - Environment.GetResourceString("ArgumentNull_String")); + SR.ArgumentNull_String); } Contract.EndContractBlock(); VerifyWritable(); @@ -733,10 +807,9 @@ namespace System.Globalization { } } - - public String[] NativeDigits + public string [] NativeDigits { - get { return (String[])nativeDigits.Clone(); } + get { return (String[]) nativeDigits.Clone(); } set { VerifyWritable(); @@ -747,25 +820,29 @@ namespace System.Globalization { public DigitShapes DigitSubstitution { - get { return (DigitShapes)digitSubstitution; } + get { return (DigitShapes) digitSubstitution; } set { VerifyWritable(); VerifyDigitSubstitution(value, nameof(DigitSubstitution)); - digitSubstitution = (int)value; + digitSubstitution = (int) value; } } - public Object GetFormat(Type formatType) { - return formatType == typeof(NumberFormatInfo)? this: null; + public Object GetFormat(Type formatType) + { + return formatType == typeof(NumberFormatInfo) ? this : null; } - public static NumberFormatInfo ReadOnly(NumberFormatInfo nfi) { - if (nfi == null) { + public static NumberFormatInfo ReadOnly(NumberFormatInfo nfi) + { + if (nfi == null) + { throw new ArgumentNullException(nameof(nfi)); } Contract.EndContractBlock(); - if (nfi.IsReadOnly) { + if (nfi.IsReadOnly) + { return (nfi); } NumberFormatInfo info = (NumberFormatInfo)(nfi.MemberwiseClone()); @@ -780,27 +857,34 @@ namespace System.Globalization { | NumberStyles.AllowThousands | NumberStyles.AllowExponent | NumberStyles.AllowCurrencySymbol | NumberStyles.AllowHexSpecifier); - internal static void ValidateParseStyleInteger(NumberStyles style) { + internal static void ValidateParseStyleInteger(NumberStyles style) + { // Check for undefined flags - if ((style & InvalidNumberStyles) != 0) { - throw new ArgumentException(Environment.GetResourceString("Argument_InvalidNumberStyles"), nameof(style)); + if ((style & InvalidNumberStyles) != 0) + { + throw new ArgumentException(SR.Argument_InvalidNumberStyles, nameof(style)); } Contract.EndContractBlock(); - if ((style & NumberStyles.AllowHexSpecifier) != 0) { // Check for hex number - if ((style & ~NumberStyles.HexNumber) != 0) { - throw new ArgumentException(Environment.GetResourceString("Arg_InvalidHexStyle")); + if ((style & NumberStyles.AllowHexSpecifier) != 0) + { // Check for hex number + if ((style & ~NumberStyles.HexNumber) != 0) + { + throw new ArgumentException(SR.Arg_InvalidHexStyle); } } } - internal static void ValidateParseStyleFloatingPoint(NumberStyles style) { + internal static void ValidateParseStyleFloatingPoint(NumberStyles style) + { // Check for undefined flags - if ((style & InvalidNumberStyles) != 0) { - throw new ArgumentException(Environment.GetResourceString("Argument_InvalidNumberStyles"), nameof(style)); + if ((style & InvalidNumberStyles) != 0) + { + throw new ArgumentException(SR.Argument_InvalidNumberStyles, nameof(style)); } Contract.EndContractBlock(); - if ((style & NumberStyles.AllowHexSpecifier) != 0) { // Check for hex number - throw new ArgumentException(Environment.GetResourceString("Arg_HexStyleNotSupported")); + if ((style & NumberStyles.AllowHexSpecifier) != 0) + { // Check for hex number + throw new ArgumentException(SR.Arg_HexStyleNotSupported); } } } // NumberFormatInfo |