// Other than that this is totally ECMA compliant.
//
+using System.Runtime.InteropServices;
+
namespace System.Globalization {
+#if NET_2_0
+ [ComVisible (true)]
+#endif
[Serializable]
public sealed class NumberFormatInfo : ICloneable, IFormatProvider {
private bool isReadOnly;
bool m_useUserOverride; // Unused, but MS.NET serializes this.
bool validForParseAsNumber; // Unused, but MS.NET serializes this.
bool validForParseAsCurrency; // Unused, but MS.NET serializes this.
+#if NET_2_0
+ string[] nativeDigits = invariantNativeDigits;
+ int digitSubstitution = 1; // DigitShapes.None.
+
+ static string [] invariantNativeDigits = new string [] {"0", "1", "2", "3", "4", "5", "6", "7", "8", "9"};
+#endif
- internal NumberFormatInfo (int lcid)
+ internal NumberFormatInfo (int lcid, bool read_only)
{
+ isReadOnly = read_only;
+
//FIXME: should add more LCID
// CultureInfo uses this one also.
if (lcid != 0x007F)
break;
}
}
+
+ internal NumberFormatInfo (bool read_only) : this (0x007f, read_only)
+ {
+ }
- public NumberFormatInfo () : this (0x007f)
+ public NumberFormatInfo () : this (false)
{
}
-
+
// this is called by mono/mono/metadata/locales.c
void InitPatterns ()
{
public int[] CurrencyGroupSizes {
get {
- return (int []) currencyGroupSizes.Clone ();
+ return (int []) RawCurrencyGroupSizes.Clone ();
+ }
+
+ set {
+ RawCurrencyGroupSizes = value;
+ }
+ }
+
+ internal int[] RawCurrencyGroupSizes {
+ get {
+ return currencyGroupSizes;
}
set {
- if (value == null || value.Length == 0)
+ if (value == null)
throw new ArgumentNullException
("The value specified for the property is a null reference");
throw new InvalidOperationException
("The current instance is read-only and a set operation was attempted");
+ if (value.Length == 0) {
+ currencyGroupSizes = new int [0];
+ return;
+ }
+
// All elements except last need to be in range 1 - 9, last can be 0.
int last = value.Length - 1;
}
}
+#if NET_2_0
+ [MonoNotSupported ("We don't have native digit info")]
+ [ComVisible (false)]
+ public string [] NativeDigits {
+ get { return nativeDigits; }
+ set {
+ if (value == null)
+ throw new ArgumentNullException ("value");
+ if (value.Length != 10)
+ throw new ArgumentException ("Argument array length must be 10");
+ foreach (string s in value)
+ if (String.IsNullOrEmpty (s))
+ throw new ArgumentException ("Argument array contains one or more null strings");
+ nativeDigits = value;
+ }
+ }
+
+ [MonoNotSupported ("We don't have native digit info")]
+ [ComVisible (false)]
+ public DigitShapes DigitSubstitution {
+ get { return (DigitShapes) digitSubstitution; }
+ set { digitSubstitution = (int) value; }
+ }
+#endif
+
public string NegativeInfinitySymbol {
get {
return negativeInfinitySymbol;
public int[] NumberGroupSizes {
get {
- return (int []) numberGroupSizes.Clone ();
+ return (int []) RawNumberGroupSizes.Clone ();
}
set {
- if (value == null || value.Length == 0)
+ RawNumberGroupSizes = value;
+ }
+ }
+
+ internal int[] RawNumberGroupSizes {
+ get {
+ return numberGroupSizes;
+ }
+
+ set {
+ if (value == null)
throw new ArgumentNullException
("The value specified for the property is a null reference");
throw new InvalidOperationException
("The current instance is read-only and a set operation was attempted");
+ if (value.Length == 0) {
+ numberGroupSizes = new int [0];
+ return;
+ }
// All elements except last need to be in range 1 - 9, last can be 0.
int last = value.Length - 1;
public int[] PercentGroupSizes {
get {
- return (int []) percentGroupSizes.Clone ();
+ return (int []) RawPercentGroupSizes.Clone ();
}
set {
- if (value == null || value.Length == 0)
+ RawPercentGroupSizes = value;
+ }
+ }
+
+ internal int[] RawPercentGroupSizes {
+ get {
+ return percentGroupSizes;
+ }
+
+ set {
+ if (value == null)
throw new ArgumentNullException
("The value specified for the property is a null reference");
throw new InvalidOperationException
("The current instance is read-only and a set operation was attempted");
-if (this == CultureInfo.CurrentCulture.NumberFormat)
-throw new Exception ("HERE the value was modified");
+ if (this == CultureInfo.CurrentCulture.NumberFormat)
+ throw new Exception ("HERE the value was modified");
+
+ if (value.Length == 0) {
+ percentGroupSizes = new int [0];
+ return;
+ }
+
// All elements except last need to be in range 1 - 9, last can be 0.
int last = value.Length - 1;