X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=blobdiff_plain;f=mcs%2Fclass%2FSystem.XML%2FSystem.Xml.Serialization%2FXmlTypeMapping.cs;h=0b64944f21dde7dc432566de173a202670cdf977;hb=018c4be8c5ef6e23ccd9bf798513a6178631e1ea;hp=79cc33a92a132b119864fc2eef468b5bafb33bfd;hpb=a303d9ab6fbfdac258a86009a7ef586cfa1e5d66;p=mono.git diff --git a/mcs/class/System.XML/System.Xml.Serialization/XmlTypeMapping.cs b/mcs/class/System.XML/System.Xml.Serialization/XmlTypeMapping.cs index 79cc33a92a1..0b64944f21d 100644 --- a/mcs/class/System.XML/System.Xml.Serialization/XmlTypeMapping.cs +++ b/mcs/class/System.XML/System.Xml.Serialization/XmlTypeMapping.cs @@ -7,17 +7,37 @@ // // (C) 2002 John Donagher // + +// +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// using System.Xml; using System; using System.Collections; +using System.Globalization; namespace System.Xml.Serialization { public class XmlTypeMapping : XmlMapping { - private string elementName; - private string ns; private string xmlType; private string xmlTypeNamespace; TypeData type; @@ -26,27 +46,29 @@ namespace System.Xml.Serialization bool isSimpleType; string documentation; bool includeInSchema; + bool isNullable = true; ArrayList _derivedTypes = new ArrayList(); internal XmlTypeMapping(string elementName, string ns, TypeData typeData, string xmlType, string xmlTypeNamespace) + : base (elementName, ns) { - this.elementName = elementName; - this.ns = ns; this.type = typeData; this.xmlType = xmlType; this.xmlTypeNamespace = xmlTypeNamespace; } +#if !NET_2_0 public string ElementName { - get { return elementName; } + get { return _elementName; } } public string Namespace { - get { return ns; } + get { return _namespace; } } +#endif public string TypeFullName { @@ -108,11 +130,18 @@ namespace System.Xml.Serialization get { return includeInSchema; } set { includeInSchema = value; } } + + internal bool IsNullable + { + get { return isNullable; } + set { isNullable = value; } + } internal XmlTypeMapping GetRealTypeMap (string objectFullTypeName) { // Returns the map for a subtype of this map's type + objectFullTypeName = objectFullTypeName.Replace ('+','.'); if (TypeFullName == objectFullTypeName) return this; for (int n=0; n<_derivedTypes.Count; n++) { XmlTypeMapping map = (XmlTypeMapping) _derivedTypes[n]; @@ -131,10 +160,12 @@ namespace System.Xml.Serialization return null; } - internal void SetRoot (XmlQualifiedName qname) + internal void UpdateRoot (XmlQualifiedName qname) { - this.elementName = qname.Name; - this.ns = qname.Namespace; + if (qname != null) { + this._elementName = qname.Name; + this._namespace = qname.Namespace; + } } } @@ -145,6 +176,7 @@ namespace System.Xml.Serialization Hashtable _elements = new Hashtable (); ArrayList _elementMembers; Hashtable _attributeMembers; + XmlTypeMapMemberAttribute[] _attributeMembersArray; XmlTypeMapElementInfo[] _elementsByIndex; ArrayList _flatLists; ArrayList _allMembers = new ArrayList (); @@ -153,6 +185,7 @@ namespace System.Xml.Serialization XmlTypeMapMemberAnyAttribute _defaultAnyAttribute; XmlTypeMapMemberNamespaces _namespaceDeclarations; XmlTypeMapMember _xmlTextCollector; + XmlTypeMapMember _returnMember; bool _ignoreMemberNamespace; bool _canBeSimpleType = true; @@ -165,6 +198,9 @@ namespace System.Xml.Serialization _membersWithDefault.Add (member); } + if (member.IsReturnValue) + _returnMember = member; + if (member is XmlTypeMapMemberAttribute) { XmlTypeMapMemberAttribute atm = (XmlTypeMapMemberAttribute)member; @@ -172,6 +208,7 @@ namespace System.Xml.Serialization string key = BuildKey (atm.AttributeName, atm.Namespace); if (_attributeMembers.ContainsKey (key)) throw new InvalidOperationException ("The XML attribute named '" + atm.AttributeName + "' from namespace '" + atm.Namespace + "' already present in the current scope. Use XML attributes to specify another XML name or namespace for the attribute."); + member.Index = _attributeMembers.Count; _attributeMembers.Add (key, member); return; } @@ -300,7 +337,16 @@ namespace System.Xml.Serialization public ICollection AttributeMembers { - get { return (_attributeMembers != null) ? _attributeMembers.Values : null; } + get + { + if (_attributeMembers == null) return null; + if (_attributeMembersArray != null) return _attributeMembersArray; + + _attributeMembersArray = new XmlTypeMapMemberAttribute[_attributeMembers.Count]; + foreach (XmlTypeMapMemberAttribute mem in _attributeMembers.Values) + _attributeMembersArray [mem.Index] = mem; + return _attributeMembersArray; + } } public ICollection ElementMembers @@ -327,6 +373,11 @@ namespace System.Xml.Serialization { get { return _xmlTextCollector; } } + + public XmlTypeMapMember ReturnMember + { + get { return _returnMember; } + } public XmlQualifiedName SimpleContentBaseType { @@ -560,7 +611,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) @@ -592,4 +643,4 @@ namespace System.Xml.Serialization return null; } } -} +}