Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'mcs/class/System.XML/System.Xml.Serialization/XmlTypeMapping.cs')
-rw-r--r--mcs/class/System.XML/System.Xml.Serialization/XmlTypeMapping.cs146
1 files changed, 72 insertions, 74 deletions
diff --git a/mcs/class/System.XML/System.Xml.Serialization/XmlTypeMapping.cs b/mcs/class/System.XML/System.Xml.Serialization/XmlTypeMapping.cs
index 960b049a10d..c772e60ff86 100644
--- a/mcs/class/System.XML/System.Xml.Serialization/XmlTypeMapping.cs
+++ b/mcs/class/System.XML/System.Xml.Serialization/XmlTypeMapping.cs
@@ -7,32 +7,32 @@
//
// (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.
-//
+
+//
+// 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;
+using System.Globalization;
using System.Xml.Schema;
namespace System.Xml.Serialization
@@ -140,10 +140,8 @@ namespace System.Xml.Serialization
internal XmlTypeMapping GetRealTypeMap (string objectFullTypeName)
{
- if (TypeData.SchemaType == SchemaTypes.Enum)
- return this;
-
// 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++) {
@@ -172,31 +170,31 @@ namespace System.Xml.Serialization
}
}
-
- // Mapping info for XmlSerializable
- internal class XmlSerializableMapping : XmlTypeMapping
- {
- XmlSchema _schema;
-
- internal XmlSerializableMapping(string elementName, string ns, TypeData typeData, string xmlType, string xmlTypeNamespace)
- : base(elementName, ns, typeData, xmlType, xmlTypeNamespace)
- {
- IXmlSerializable serializable = (IXmlSerializable)Activator.CreateInstance(typeData.Type);
- _schema = serializable.GetSchema();
- if (_schema != null)
- {
- if (_schema.Id == null || _schema.Id.Length == 0)
- throw new InvalidOperationException("Schema Id is missing. The schema returned from " + typeData.Type.FullName + ".GetSchema() must have an Id.");
- }
- }
-
- internal XmlSchema Schema
- {
- get { return _schema; }
- }
- }
-
-
+
+ // Mapping info for XmlSerializable
+ internal class XmlSerializableMapping : XmlTypeMapping
+ {
+ XmlSchema _schema;
+
+ internal XmlSerializableMapping(string elementName, string ns, TypeData typeData, string xmlType, string xmlTypeNamespace)
+ : base(elementName, ns, typeData, xmlType, xmlTypeNamespace)
+ {
+ IXmlSerializable serializable = (IXmlSerializable)Activator.CreateInstance(typeData.Type);
+ _schema = serializable.GetSchema();
+ if (_schema != null)
+ {
+ if (_schema.Id == null || _schema.Id.Length == 0)
+ throw new InvalidOperationException("Schema Id is missing. The schema returned from " + typeData.Type.FullName + ".GetSchema() must have an Id.");
+ }
+ }
+
+ internal XmlSchema Schema
+ {
+ get { return _schema; }
+ }
+ }
+
+
// Mapping info for classes and structs
internal class ClassMap: ObjectMap
@@ -283,9 +281,9 @@ namespace System.Xml.Serialization
if (_elements.ContainsKey (key))
throw new InvalidOperationException ("The XML element named '" + elem.ElementName + "' from namespace '" + elem.Namespace + "' is already present in the current scope. Use XML attributes to specify another XML name or namespace for the element.");
_elements.Add (key, elem);
- }
-
- if (member.TypeData.IsListType && member.TypeData.Type != null && !member.TypeData.Type.IsArray) {
+ }
+
+ if (member.TypeData.IsListType && member.TypeData.Type != null && !member.TypeData.Type.IsArray) {
if (_listMembers == null) _listMembers = new ArrayList ();
_listMembers.Add (member);
}
@@ -401,12 +399,12 @@ namespace System.Xml.Serialization
public ArrayList MembersWithDefault
{
get { return _membersWithDefault; }
- }
-
+ }
+
public ArrayList ListMembers
{
get { return _listMembers; }
- }
+ }
public XmlTypeMapMember XmlTextCollector
{
@@ -454,8 +452,8 @@ namespace System.Xml.Serialization
{
XmlTypeMapElementInfoList _itemInfo;
bool _gotNestedMapping;
- XmlTypeMapping _nestedArrayMapping;
- string _choiceMember;
+ XmlTypeMapping _nestedArrayMapping;
+ string _choiceMember;
public bool IsMultiArray
{
@@ -465,12 +463,12 @@ namespace System.Xml.Serialization
}
}
- public string ChoiceMember
- {
- get { return _choiceMember; }
- set { _choiceMember = value; }
- }
-
+ public string ChoiceMember
+ {
+ get { return _choiceMember; }
+ set { _choiceMember = value; }
+ }
+
public XmlTypeMapping NestedArrayMapping
{
get
@@ -507,16 +505,16 @@ namespace System.Xml.Serialization
{
if (_itemInfo.Count == 1)
return (XmlTypeMapElementInfo) _itemInfo[0];
- else if (_choiceMember != null && index != -1)
- {
- Array values = (Array) XmlTypeMapMember.GetValue (ob, _choiceMember);
- if (values == null || index >= values.Length)
- throw new InvalidOperationException ("Invalid or missing choice enum value in member '" + _choiceMember + "'.");
- object val = values.GetValue (index);
- foreach (XmlTypeMapElementInfo elem in _itemInfo)
- if (elem.ChoiceValue != null && elem.ChoiceValue.Equals (val))
- return elem;
- }
+ else if (_choiceMember != null && index != -1)
+ {
+ Array values = (Array) XmlTypeMapMember.GetValue (ob, _choiceMember);
+ if (values == null || index >= values.Length)
+ throw new InvalidOperationException ("Invalid or missing choice enum value in member '" + _choiceMember + "'.");
+ object val = values.GetValue (index);
+ foreach (XmlTypeMapElementInfo elem in _itemInfo)
+ if (elem.ChoiceValue != null && elem.ChoiceValue.Equals (val))
+ return elem;
+ }
else
{
if (memberValue == null) return null;