//\r
// (C) 2002 John Donagher\r
//\r
+
+//
+// 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.
+//
\r
using System.Xml;\r
using System;\r
using System.Collections;\r
+using System.Globalization;\r
\r
namespace System.Xml.Serialization\r
{\r
public class XmlTypeMapping : XmlMapping\r
{\r
- private string elementName;\r
- private string ns;\r
private string xmlType;\r
private string xmlTypeNamespace;\r
TypeData type;\r
bool isSimpleType;\r
string documentation;\r
bool includeInSchema;\r
+ bool isNullable = true;\r
\r
ArrayList _derivedTypes = new ArrayList();\r
\r
internal XmlTypeMapping(string elementName, string ns, TypeData typeData, string xmlType, string xmlTypeNamespace)\r
+ : base (elementName, ns)\r
{\r
- this.elementName = elementName;\r
- this.ns = ns;\r
this.type = typeData;\r
this.xmlType = xmlType;\r
this.xmlTypeNamespace = xmlTypeNamespace;\r
}\r
\r
+#if !NET_2_0\r
public string ElementName\r
{\r
- get { return elementName; }\r
+ get { return _elementName; }\r
}\r
\r
public string Namespace\r
{\r
- get { return ns; }\r
+ get { return _namespace; }\r
}\r
+#endif\r
\r
public string TypeFullName\r
{\r
get { return includeInSchema; }\r
set { includeInSchema = value; }\r
}\r
+ \r
+ internal bool IsNullable\r
+ {\r
+ get { return isNullable; }\r
+ set { isNullable = value; }\r
+ }\r
\r
internal XmlTypeMapping GetRealTypeMap (string objectFullTypeName)\r
{\r
// Returns the map for a subtype of this map's type\r
\r
+ objectFullTypeName = objectFullTypeName.Replace ('+','.');\r
if (TypeFullName == objectFullTypeName) return this;\r
for (int n=0; n<_derivedTypes.Count; n++) {\r
XmlTypeMapping map = (XmlTypeMapping) _derivedTypes[n];\r
return null;\r
}\r
\r
- internal void SetRoot (XmlQualifiedName qname)\r
+ internal void UpdateRoot (XmlQualifiedName qname)\r
{\r
- this.elementName = qname.Name;\r
- this.ns = qname.Namespace;\r
+ if (qname != null) {\r
+ this._elementName = qname.Name;\r
+ this._namespace = qname.Namespace;\r
+ }\r
}\r
}\r
\r
Hashtable _elements = new Hashtable ();\r
ArrayList _elementMembers;\r
Hashtable _attributeMembers;\r
+ XmlTypeMapMemberAttribute[] _attributeMembersArray;\r
XmlTypeMapElementInfo[] _elementsByIndex;\r
ArrayList _flatLists;\r
ArrayList _allMembers = new ArrayList ();\r
XmlTypeMapMemberAnyAttribute _defaultAnyAttribute;\r
XmlTypeMapMemberNamespaces _namespaceDeclarations;\r
XmlTypeMapMember _xmlTextCollector;\r
+ XmlTypeMapMember _returnMember;\r
bool _ignoreMemberNamespace;\r
bool _canBeSimpleType = true;\r
\r
_membersWithDefault.Add (member);\r
}\r
\r
+ if (member.IsReturnValue)\r
+ _returnMember = member;\r
+ \r
if (member is XmlTypeMapMemberAttribute)\r
{\r
XmlTypeMapMemberAttribute atm = (XmlTypeMapMemberAttribute)member;\r
string key = BuildKey (atm.AttributeName, atm.Namespace);\r
if (_attributeMembers.ContainsKey (key))\r
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.");\r
+ member.Index = _attributeMembers.Count;\r
_attributeMembers.Add (key, member);\r
return;\r
}\r
\r
public ICollection AttributeMembers\r
{\r
- get { return (_attributeMembers != null) ? _attributeMembers.Values : null; }\r
+ get \r
+ {\r
+ if (_attributeMembers == null) return null;\r
+ if (_attributeMembersArray != null) return _attributeMembersArray;\r
+ \r
+ _attributeMembersArray = new XmlTypeMapMemberAttribute[_attributeMembers.Count];\r
+ foreach (XmlTypeMapMemberAttribute mem in _attributeMembers.Values)\r
+ _attributeMembersArray [mem.Index] = mem;\r
+ return _attributeMembersArray;\r
+ }\r
}\r
\r
public ICollection ElementMembers\r
{\r
get { return _xmlTextCollector; }\r
}\r
+ \r
+ public XmlTypeMapMember ReturnMember\r
+ {\r
+ get { return _returnMember; }\r
+ }\r
\r
public XmlQualifiedName SimpleContentBaseType\r
{\r
foreach (EnumMapMember mem in _members)\r
if (mem.EnumName == enumName) return mem.XmlName;\r
\r
- return Convert.ToInt64(enumValue).ToString();\r
+ return Convert.ToInt64(enumValue).ToString(CultureInfo.InvariantCulture);\r
}\r
\r
public string GetEnumName (string xmlName)\r
return null;\r
}\r
}\r
-}
+}\r