diff options
author | Atsushi Eno <atsushieno@gmail.com> | 2004-06-18 13:50:34 +0400 |
---|---|---|
committer | Atsushi Eno <atsushieno@gmail.com> | 2004-06-18 13:50:34 +0400 |
commit | a5eaabf6f167e67b323a8f18d7291d29326fc6b2 (patch) | |
tree | e89733169badd1e59b5723b241bd51994d0804ff | |
parent | e2041f94d737c127f7dfb090aba0b97dbdafb9e6 (diff) |
2004-06-18 Atsushi Enomoto <atsushi@ximian.com>
* CodeIdentifier.cs, CodeIdentifiers.cs, MapCodeGenerator.cs,
SerializationCodeGenerator.cs, SerializationSource.cs,
TypeTranslator.cs, XmlAttributeOverrides.cs, XmlCustomFormatter.cs,
XmlSerializationReader.cs, XmlSerializationWriter.cs,
XmlSerializer.cs, XmlTypeMapMemberElement.cs, XmlTypeMapping.cs
: Globalization fixes.
In XmlCustomFormatter.GenerateToXmlString() time was not
generated correctly.
Replaced all CRLF XmlAttributeOverrides.cs into LF.
svn path=/trunk/mcs/; revision=29865
14 files changed, 137 insertions, 110 deletions
diff --git a/mcs/class/System.XML/System.Xml.Serialization/ChangeLog b/mcs/class/System.XML/System.Xml.Serialization/ChangeLog index f10b261829c..4ca79ed1c64 100755 --- a/mcs/class/System.XML/System.Xml.Serialization/ChangeLog +++ b/mcs/class/System.XML/System.Xml.Serialization/ChangeLog @@ -1,3 +1,15 @@ +2004-06-18 Atsushi Enomoto <atsushi@ximian.com> + + * CodeIdentifier.cs, CodeIdentifiers.cs, MapCodeGenerator.cs, + SerializationCodeGenerator.cs, SerializationSource.cs, + TypeTranslator.cs, XmlAttributeOverrides.cs, XmlCustomFormatter.cs, + XmlSerializationReader.cs, XmlSerializationWriter.cs, + XmlSerializer.cs, XmlTypeMapMemberElement.cs, XmlTypeMapping.cs + : Globalization fixes. + In XmlCustomFormatter.GenerateToXmlString() time was not + generated correctly. + Replaced all CRLF XmlAttributeOverrides.cs into LF. + 2004-06-13 Gert Driesen <drieseng@users.sourceforge.net> * XmlSerializationWriter.cs: changed signature of protected method diff --git a/mcs/class/System.XML/System.Xml.Serialization/CodeIdentifier.cs b/mcs/class/System.XML/System.Xml.Serialization/CodeIdentifier.cs index ab8c25a7e63..73adc825df2 100644 --- a/mcs/class/System.XML/System.Xml.Serialization/CodeIdentifier.cs +++ b/mcs/class/System.XML/System.Xml.Serialization/CodeIdentifier.cs @@ -8,6 +8,7 @@ // using System; +using System.Globalization; namespace System.Xml.Serialization { public class CodeIdentifier { @@ -19,13 +20,13 @@ namespace System.Xml.Serialization { public static string MakeCamel (string identifier) { string validIdentifier = MakeValid (identifier); - return (Char.ToLower (validIdentifier[0]) + validIdentifier.Substring (1)); + return (Char.ToLower (validIdentifier[0], CultureInfo.InvariantCulture) + validIdentifier.Substring (1)); } public static string MakePascal (string identifier) { string validIdentifier = MakeValid (identifier); - return (Char.ToUpper (validIdentifier[0]) + validIdentifier.Substring (1)); + return (Char.ToUpper (validIdentifier[0], CultureInfo.InvariantCulture) + validIdentifier.Substring (1)); } public static string MakeValid (string identifier) diff --git a/mcs/class/System.XML/System.Xml.Serialization/CodeIdentifiers.cs b/mcs/class/System.XML/System.Xml.Serialization/CodeIdentifiers.cs index 0cd713946c8..398e842b6f6 100644 --- a/mcs/class/System.XML/System.Xml.Serialization/CodeIdentifiers.cs +++ b/mcs/class/System.XML/System.Xml.Serialization/CodeIdentifiers.cs @@ -9,6 +9,7 @@ using System;
using System.Collections;
+using System.Globalization;
namespace System.Xml.Serialization {
public class CodeIdentifiers {
@@ -81,7 +82,7 @@ namespace System.Xml.Serialization { int i = 1;
while (IsInUse (uniqueIdentifier)) {
- uniqueIdentifier = String.Format ("{0}{1}", identifier, i.ToString ());
+ uniqueIdentifier = String.Format (CultureInfo.InvariantCulture, "{0}{1}", identifier, i);
i += 1;
}
diff --git a/mcs/class/System.XML/System.Xml.Serialization/MapCodeGenerator.cs b/mcs/class/System.XML/System.Xml.Serialization/MapCodeGenerator.cs index 3782f003de1..d7629f97ed7 100644 --- a/mcs/class/System.XML/System.Xml.Serialization/MapCodeGenerator.cs +++ b/mcs/class/System.XML/System.Xml.Serialization/MapCodeGenerator.cs @@ -9,6 +9,7 @@ using System.CodeDom; using System.Collections; +using System.Globalization; using System.Xml.Schema; namespace System.Xml.Serialization { @@ -527,8 +528,9 @@ namespace System.Xml.Serialization { // It must be an enumeration defined in the schema. if (typeData.SchemaType != SchemaTypes.Enum) throw new InvalidOperationException ("Type " + typeData.TypeName + " not supported"); - - CodeFieldReferenceExpression fref = new CodeFieldReferenceExpression (new CodeTypeReferenceExpression (typeData.FullTypeName), defaultValue.ToString()); + + IFormattable defaultValueFormattable = defaultValue as IFormattable; + CodeFieldReferenceExpression fref = new CodeFieldReferenceExpression (new CodeTypeReferenceExpression (typeData.FullTypeName), defaultValueFormattable != null ? defaultValueFormattable.ToString(null, CultureInfo.InvariantCulture) : defaultValue.ToString ()); CodeAttributeArgument arg = new CodeAttributeArgument (fref); AddCustomAttribute (codeField, "System.ComponentModel.DefaultValue", arg); codeField.InitExpression = fref; diff --git a/mcs/class/System.XML/System.Xml.Serialization/SerializationCodeGenerator.cs b/mcs/class/System.XML/System.Xml.Serialization/SerializationCodeGenerator.cs index c4430bf9af0..67729397435 100644 --- a/mcs/class/System.XML/System.Xml.Serialization/SerializationCodeGenerator.cs +++ b/mcs/class/System.XML/System.Xml.Serialization/SerializationCodeGenerator.cs @@ -11,6 +11,7 @@ using System.IO; using System.Reflection; using System.Xml.Serialization; using System.Collections; +using System.Globalization; namespace System.Xml.Serialization { @@ -369,7 +370,7 @@ namespace System.Xml.Serialization Unindent (); } else - WriteLine ("default: return ((long)val).ToString();"); + WriteLine ("default: return ((long)val).ToString(CultureInfo.InvariantCulture);"); WriteLineUni ("}"); @@ -2003,7 +2004,7 @@ namespace System.Xml.Serialization } WriteLineInd ("default:"); WriteLineInd ("try {"); - WriteLine ("return (" + typeMap.TypeFullName + ") Int64.Parse (" + val + ");"); + WriteLine ("return (" + typeMap.TypeFullName + ") Int64.Parse (" + val + ", CultureInfo.InvariantCulture);"); WriteLineUni ("}"); WriteLineInd ("catch {"); WriteLine ("throw CreateUnknownConstantException (" + val + ", typeof(" + typeMap.TypeFullName + "));"); @@ -2347,7 +2348,7 @@ namespace System.Xml.Serialization XmlQualifiedName qn = (XmlQualifiedName)ob; return "new XmlQualifiedName (" + GetLiteral(qn.Name) + "," + GetLiteral(qn.Namespace) + ")"; } - else return ob.ToString (); + else return (ob is IFormattable) ? ((IFormattable) ob).ToString (null, CultureInfo.InvariantCulture) : ob.ToString (); } void WriteLineInd (string code) diff --git a/mcs/class/System.XML/System.Xml.Serialization/SerializationSource.cs b/mcs/class/System.XML/System.Xml.Serialization/SerializationSource.cs index ac8a44a5cc9..df435f3f849 100644 --- a/mcs/class/System.XML/System.Xml.Serialization/SerializationSource.cs +++ b/mcs/class/System.XML/System.Xml.Serialization/SerializationSource.cs @@ -8,6 +8,7 @@ // using System.Collections; +using System.Globalization; using System.Text; namespace System.Xml.Serialization @@ -141,7 +142,7 @@ namespace System.Xml.Serialization this.literalFormat = literalFormat; StringBuilder sb = new StringBuilder (); - sb.Append (members.Length.ToString()); + sb.Append (members.Length.ToString(CultureInfo.InvariantCulture)); foreach (XmlReflectionMember mem in members) mem.AddKeyHash (sb); @@ -178,7 +179,7 @@ namespace System.Xml.Serialization { if (val != def) { sb.Append (n.ToString()); - sb.Append (val.Length.ToString()); + sb.Append (val.Length.ToString(CultureInfo.InvariantCulture)); sb.Append (val); } } @@ -198,14 +199,14 @@ namespace System.Xml.Serialization { if (val != def) { sb.Append (n.ToString()); - sb.Append (val.ToString()); + sb.Append (val.ToString(CultureInfo.InvariantCulture)); } } public static void AddField (StringBuilder sb, int n, Type val) { if (val != null) { - sb.Append (n.ToString()); + sb.Append (n.ToString(CultureInfo.InvariantCulture)); sb.Append (val.ToString()); } } diff --git a/mcs/class/System.XML/System.Xml.Serialization/TypeTranslator.cs b/mcs/class/System.XML/System.Xml.Serialization/TypeTranslator.cs index 3966c6e047f..8147f7b9aa3 100644 --- a/mcs/class/System.XML/System.Xml.Serialization/TypeTranslator.cs +++ b/mcs/class/System.XML/System.Xml.Serialization/TypeTranslator.cs @@ -12,6 +12,7 @@ using System; using System.Collections; +using System.Globalization; namespace System.Xml.Serialization { @@ -154,7 +155,7 @@ namespace System.Xml.Serialization public static string GetArrayName (string elemName) { - return "ArrayOf" + Char.ToUpper (elemName [0]) + elemName.Substring (1); + return "ArrayOf" + Char.ToUpper (elemName [0], CultureInfo.InvariantCulture) + elemName.Substring (1); } public static string GetArrayName (string elemName, int dimensions) diff --git a/mcs/class/System.XML/System.Xml.Serialization/XmlAttributeOverrides.cs b/mcs/class/System.XML/System.Xml.Serialization/XmlAttributeOverrides.cs index 7138756f426..2a58f9490c2 100644 --- a/mcs/class/System.XML/System.Xml.Serialization/XmlAttributeOverrides.cs +++ b/mcs/class/System.XML/System.Xml.Serialization/XmlAttributeOverrides.cs @@ -7,65 +7,67 @@ // (C) 2002 John Donagher // -using System;
-using System.Collections;
-
-namespace System.Xml.Serialization
-{
- /// <summary>
- /// Summary description for XmlAttributeOverrides.
- /// </summary>
- public class XmlAttributeOverrides
- {
-
- private Hashtable overrides;
-
- public XmlAttributeOverrides ()
- {
- overrides = new Hashtable();
- }
-
- public XmlAttributes this [Type type]
- {
- get { return this [type, string.Empty]; }
- }
-
- public XmlAttributes this [Type type, string member]
- {
- get
- {
- return (XmlAttributes) overrides[GetKey(type,member)];
- }
- }
-
- public void Add (Type type, XmlAttributes attributes)
- {
- Add(type, string.Empty, attributes);
- }
-
- public void Add (Type type, string member, XmlAttributes attributes)
- {
- if(overrides[GetKey(type, member)] != null)
- throw new Exception("The attributes for the given type and Member already exist in the collection");
-
- overrides.Add(GetKey(type,member), attributes);
- }
-
- private TypeMember GetKey(Type type, string member)
- {
- return new TypeMember(type, member);
- }
-
- internal void AddKeyHash (System.Text.StringBuilder sb)
- {
- sb.Append ("XAO ");
- foreach (DictionaryEntry entry in overrides)
- {
- XmlAttributes val = (XmlAttributes) entry.Value;
- sb.Append (entry.Key.ToString()).Append(' ');
- val.AddKeyHash (sb);
- }
- sb.Append ("|");
- }
- }
+using System; +using System.Collections; +using System.Globalization; + +namespace System.Xml.Serialization +{ + /// <summary> + /// Summary description for XmlAttributeOverrides. + /// </summary> + public class XmlAttributeOverrides + { + + private Hashtable overrides; + + public XmlAttributeOverrides () + { + overrides = new Hashtable(); + } + + public XmlAttributes this [Type type] + { + get { return this [type, string.Empty]; } + } + + public XmlAttributes this [Type type, string member] + { + get + { + return (XmlAttributes) overrides[GetKey(type,member)]; + } + } + + public void Add (Type type, XmlAttributes attributes) + { + Add(type, string.Empty, attributes); + } + + public void Add (Type type, string member, XmlAttributes attributes) + { + if(overrides[GetKey(type, member)] != null) + throw new Exception("The attributes for the given type and Member already exist in the collection"); + + overrides.Add(GetKey(type,member), attributes); + } + + private TypeMember GetKey(Type type, string member) + { + return new TypeMember(type, member); + } + + internal void AddKeyHash (System.Text.StringBuilder sb) + { + sb.Append ("XAO "); + foreach (DictionaryEntry entry in overrides) + { + XmlAttributes val = (XmlAttributes) entry.Value; + IFormattable keyFormattable = entry.Key as IFormattable; + sb.Append (keyFormattable != null ? keyFormattable.ToString (null, CultureInfo.InvariantCulture) : entry.Key.ToString()).Append(' '); + val.AddKeyHash (sb); + } + sb.Append ("|"); + } + } } diff --git a/mcs/class/System.XML/System.Xml.Serialization/XmlCustomFormatter.cs b/mcs/class/System.XML/System.Xml.Serialization/XmlCustomFormatter.cs index ac03f3931fc..dd007c15d0e 100644 --- a/mcs/class/System.XML/System.Xml.Serialization/XmlCustomFormatter.cs +++ b/mcs/class/System.XML/System.Xml.Serialization/XmlCustomFormatter.cs @@ -3,7 +3,7 @@ // // Author: // Tim Coleman (tim@timcoleman.com) -// Lluis Sanchez Gual (lluis@ximian.com)
+// Lluis Sanchez Gual (lluis@ximian.com) // // Copyright (C) Tim Coleman, 2002 // @@ -29,13 +29,13 @@ namespace System.Xml.Serialization { if (value == null) return null; StringBuilder output = new StringBuilder (); foreach (byte val in value) - output.Append (val.ToString ("X2")); + output.Append (val.ToString ("X2", CultureInfo.InvariantCulture)); return output.ToString (); } internal static string FromChar (char value) { - return ((int) value).ToString (); + return ((int) value).ToString (CultureInfo.InvariantCulture); } internal static string FromDate (DateTime value) @@ -175,7 +175,7 @@ namespace System.Xml.Serialization { case "unsignedLong": return XmlConvert.ToString ((UInt64)value); case "guid": return XmlConvert.ToString ((Guid)value); case "base64Binary": return Convert.ToBase64String ((byte[])value); - default: return value.ToString (); + default: return value is IFormattable ? ((IFormattable) value).ToString (null, CultureInfo.InvariantCulture) : value.ToString (); } } @@ -216,21 +216,21 @@ namespace System.Xml.Serialization { switch (type.XmlType) { case "boolean": return "(" + value + "?\"true\":\"false\")"; - case "unsignedByte": return value + ".ToString()"; - case "char": return "((int)(" + value + ")).ToString()"; + case "unsignedByte": return value + ".ToString(CultureInfo.InvariantCulture)"; + case "char": return "((int)(" + value + ")).ToString(CultureInfo.InvariantCulture)"; case "dateTime": return value + ".ToString(\"yyyy-MM-ddTHH:mm:ss.fffffffzzz\", CultureInfo.InvariantCulture)"; case "date": return value + ".ToString(\"yyyy-MM-dd\", CultureInfo.InvariantCulture)"; - case "time": return value + ".ToString(\"HH:mm:ss.fffffffzzz\", CultureInfo.InvariantCulture"; + case "time": return value + ".ToString(\"HH:mm:ss.fffffffzzz\", CultureInfo.InvariantCulture)"; case "decimal": return "XmlConvert.ToString (" + value + ")"; case "double": return "XmlConvert.ToString (" + value + ")"; - case "short": return value + ".ToString()"; - case "int": return value + ".ToString()"; - case "long": return value + ".ToString()"; - case "byte": return value + ".ToString()"; + case "short": return value + ".ToString(CultureInfo.InvariantCulture)"; + case "int": return value + ".ToString(CultureInfo.InvariantCulture)"; + case "long": return value + ".ToString(CultureInfo.InvariantCulture)"; + case "byte": return value + ".ToString(CultureInfo.InvariantCulture)"; case "float": return "XmlConvert.ToString (" + value + ")"; - case "unsignedShort": return value + ".ToString()"; - case "unsignedInt": return value + ".ToString()"; - case "unsignedLong": return value + ".ToString()"; + case "unsignedShort": return value + ".ToString(CultureInfo.InvariantCulture)"; + case "unsignedInt": return value + ".ToString(CultureInfo.InvariantCulture)"; + case "unsignedLong": return value + ".ToString(CultureInfo.InvariantCulture)"; case "guid": return "XmlConvert.ToString (" + value + ")"; case "base64Binary": return "Convert.ToBase64String (" + value + ")"; case "NMTOKEN": @@ -253,21 +253,21 @@ namespace System.Xml.Serialization { switch (type.XmlType) { case "boolean": return "XmlConvert.ToBoolean (" + value + ")"; - case "unsignedByte": return "byte.Parse(" + value + ")"; - case "char": return "(char)Int32.Parse (" + value + ")"; + case "unsignedByte": return "byte.Parse (" + value + ", CultureInfo.InvariantCulture)"; + case "char": return "(char)Int32.Parse (" + value + ", CultureInfo.InvariantCulture)"; case "dateTime": return "XmlConvert.ToDateTime (" + value + ")"; - case "date": return "DateTime.ParseExact (" + value + ", \"yyyy-MM-dd\", null)"; - case "time": return "DateTime.ParseExact (" + value + ", \"HH:mm:ss.fffffffzzz\", null)"; - case "decimal": return "Decimal.Parse (" + value + ")"; + case "date": return "DateTime.ParseExact (" + value + ", \"yyyy-MM-dd\", CultureInfo.InvariantCulture)"; + case "time": return "DateTime.ParseExact (" + value + ", \"HH:mm:ss.fffffffzzz\", CultureInfo.InvariantCulture)"; + case "decimal": return "Decimal.Parse (" + value + ", CultureInfo.InvariantCulture)"; case "double": return "XmlConvert.ToDouble (" + value + ")"; - case "short": return "Int16.Parse (" + value + ")"; - case "int": return "Int32.Parse (" + value + ")"; - case "long": return "Int64.Parse (" + value + ")"; - case "byte": return "SByte.Parse (" + value + ")"; - case "float": return "XmlConvert.ToSingle (" + value + ")"; - case "unsignedShort": return "UInt16.Parse (" + value + ")"; - case "unsignedInt": return "UInt32.Parse (" + value + ")"; - case "unsignedLong": return "UInt64.Parse (" + value + ")"; + case "short": return "Int16.Parse (" + value + ", CultureInfo.InvariantCulture)"; + case "int": return "Int32.Parse (" + value + ", CultureInfo.InvariantCulture)"; + case "long": return "Int64.Parse (" + value + ", CultureInfo.InvariantCulture)"; + case "byte": return "SByte.Parse (" + value + ", CultureInfo.InvariantCulture)"; + case "float": return "XmlConvert.ToSingle (" + value + ", CultureInfo.InvariantCulture)"; + case "unsignedShort": return "UInt16.Parse (" + value + ", CultureInfo.InvariantCulture)"; + case "unsignedInt": return "UInt32.Parse (" + value + ", CultureInfo.InvariantCulture)"; + case "unsignedLong": return "UInt64.Parse (" + value + ", CultureInfo.InvariantCulture)"; case "guid": return "XmlConvert.ToGuid (" + value + ")"; case "base64Binary": return "Convert.FromBase64String (" + value + ")"; default: return value; diff --git a/mcs/class/System.XML/System.Xml.Serialization/XmlSerializationReader.cs b/mcs/class/System.XML/System.Xml.Serialization/XmlSerializationReader.cs index 377f1dfabc4..4388735df52 100644 --- a/mcs/class/System.XML/System.Xml.Serialization/XmlSerializationReader.cs +++ b/mcs/class/System.XML/System.Xml.Serialization/XmlSerializationReader.cs @@ -12,6 +12,7 @@ using System; using System.Collections; +using System.Globalization; using System.Xml; using System.Xml.Schema; @@ -216,7 +217,7 @@ namespace System.Xml.Serialization { protected Exception CreateInvalidCastException (Type type, object value) { - string message = String.Format ("Cannot assign object of type {0} to an object of " + + string message = String.Format (CultureInfo.InvariantCulture, "Cannot assign object of type {0} to an object of " + "type {1}.", value.GetType (), type); return new InvalidCastException (message); } @@ -495,7 +496,7 @@ namespace System.Xml.Serialization { int i = qn.Name.LastIndexOf ('['); string dim = qn.Name.Substring (i); string itemType = qn.Name.Substring (0,i); - int count = Int32.Parse (dim.Substring (1, dim.Length - 2)); + int count = Int32.Parse (dim.Substring (1, dim.Length - 2), CultureInfo.InvariantCulture); Array list; diff --git a/mcs/class/System.XML/System.Xml.Serialization/XmlSerializationWriter.cs b/mcs/class/System.XML/System.Xml.Serialization/XmlSerializationWriter.cs index 29908a3622a..b0b144a20cd 100644 --- a/mcs/class/System.XML/System.Xml.Serialization/XmlSerializationWriter.cs +++ b/mcs/class/System.XML/System.Xml.Serialization/XmlSerializationWriter.cs @@ -10,6 +10,7 @@ using System; using System.Collections; +using System.Globalization; using System.Text; using System.Xml; using System.Xml.Schema; @@ -194,7 +195,7 @@ namespace System.Xml.Serialization { bool firstTime; long lid = idGenerator.GetId (o, out firstTime); - return String.Format ("id{0}", lid); + return String.Format (CultureInfo.InvariantCulture, "id{0}", lid); } @@ -212,7 +213,7 @@ namespace System.Xml.Serialization { string prefix = Writer.LookupPrefix (ns); if (prefix == null) { - prefix = String.Format ("q{0}", ++qnameCount); + prefix = String.Format (CultureInfo.InvariantCulture, "q{0}", ++qnameCount); WriteAttribute ("xmlns", prefix, null, ns); } return prefix; diff --git a/mcs/class/System.XML/System.Xml.Serialization/XmlSerializer.cs b/mcs/class/System.XML/System.Xml.Serialization/XmlSerializer.cs index d22219b5cb4..26e70f7af12 100644 --- a/mcs/class/System.XML/System.Xml.Serialization/XmlSerializer.cs +++ b/mcs/class/System.XML/System.Xml.Serialization/XmlSerializer.cs @@ -10,6 +10,7 @@ using System; using System.Threading; using System.Collections; +using System.Globalization; using System.IO; using System.Reflection; using System.Xml; @@ -77,10 +78,10 @@ namespace System.Xml.Serialization generationThreshold = 50; backgroundGeneration = true; } - else if (th.ToLower() == "no") + else if (th.ToLower(CultureInfo.InvariantCulture) == "no") generationThreshold = -1; else { - generationThreshold = int.Parse (th); + generationThreshold = int.Parse (th, CultureInfo.InvariantCulture); backgroundGeneration = (generationThreshold != 0); if (generationThreshold < 1) generationThreshold = 1; } diff --git a/mcs/class/System.XML/System.Xml.Serialization/XmlTypeMapMemberElement.cs b/mcs/class/System.XML/System.Xml.Serialization/XmlTypeMapMemberElement.cs index 4d33c76d4e1..c81763db2ad 100644 --- a/mcs/class/System.XML/System.Xml.Serialization/XmlTypeMapMemberElement.cs +++ b/mcs/class/System.XML/System.Xml.Serialization/XmlTypeMapMemberElement.cs @@ -9,6 +9,7 @@ using System; using System.Collections; +using System.Globalization; namespace System.Xml.Serialization { @@ -47,7 +48,8 @@ namespace System.Xml.Serialization return (XmlTypeMapElementInfo) _elementInfo[0]; else if (_choiceMember != null) { - string choiceValue = GetValue (ob, _choiceMember).ToString(); + object value = GetValue (ob, _choiceMember); + string choiceValue = value is IFormattable ? ((IFormattable) value).ToString (null, CultureInfo.InvariantCulture) : value.ToString(); foreach (XmlTypeMapElementInfo elem in _elementInfo) if (elem.ChoiceValue == choiceValue) return elem; } diff --git a/mcs/class/System.XML/System.Xml.Serialization/XmlTypeMapping.cs b/mcs/class/System.XML/System.Xml.Serialization/XmlTypeMapping.cs index 140f944d5a1..14d413ccfa0 100644 --- a/mcs/class/System.XML/System.Xml.Serialization/XmlTypeMapping.cs +++ b/mcs/class/System.XML/System.Xml.Serialization/XmlTypeMapping.cs @@ -11,6 +11,7 @@ using System.Xml;
using System;
using System.Collections;
+using System.Globalization;
namespace System.Xml.Serialization
{
@@ -590,7 +591,7 @@ namespace System.Xml.Serialization foreach (EnumMapMember mem in _members)
if (mem.EnumName == enumName) return mem.XmlName;
- return Convert.ToInt64(enumValue).ToString();
+ return Convert.ToInt64(enumValue).ToString(CultureInfo.InvariantCulture);
}
public string GetEnumName (string xmlName)
@@ -622,4 +623,4 @@ namespace System.Xml.Serialization return null;
}
}
-} +}
|