Jelajahi Sumber

* XmlSerializationReader.cs, XmlSerializationReaderInterpreter.cs: Minor fixes.

svn path=/trunk/mcs/; revision=15301
Lluis Sanchez 22 tahun lalu
induk
melakukan
4c174fcaa1

+ 4 - 0
mcs/class/System.XML/System.Xml.Serialization/ChangeLog

@@ -1,3 +1,7 @@
+2003-06-11  Lluis Sanchez Gual <[email protected]>
+
+	* XmlSerializationReader.cs, XmlSerializationReaderInterpreter.cs: Minor fixes.
+
 2003-06-10  Lluis Sanchez Gual <[email protected]>
 
 	* SoapReflectionImporter.cs: Added check: some overrides cannot be applied to primitive types.

+ 17 - 10
mcs/class/System.XML/System.Xml.Serialization/XmlSerializationReader.cs

@@ -4,7 +4,7 @@
 // Authors:
 // 	Tim Coleman ([email protected])
 // 	Gonzalo Paniagua Javier ([email protected])
-//  Lluis Sanchez Gual ([email protected])
+//  Lluis Sanchez Gual ([email protected])
 //
 // Copyright (C) Tim Coleman, 2002
 // (c) 2002 Ximian, Inc. (http://www.ximian.com)
@@ -72,11 +72,11 @@ namespace System.Xml.Serialization {
 			InitIDs ();
 		}
 			
-		internal virtual object ReadObject ()
-		{
+		internal virtual object ReadObject ()
+		{
 			throw new NotImplementedException ();
-		}
-
+		}
+
 		private ArrayList EnsureArrayList (ArrayList list)
 		{
 			if (list == null)
@@ -116,8 +116,10 @@ namespace System.Xml.Serialization {
 			collFixups = EnsureHashtable (collFixups);
 			collFixups [fixup.Id] = fixup;
 
-			if (delayedListFixups != null && delayedListFixups.ContainsKey (fixup.Id))
+			if (delayedListFixups != null && delayedListFixups.ContainsKey (fixup.Id)) {
 				fixup.CollectionItems = delayedListFixups [fixup.Id];
+				delayedListFixups.Remove (fixup.Id);
+			}
 		}
 
 		protected void AddFixup (Fixup fixup)
@@ -498,6 +500,11 @@ namespace System.Xml.Serialization {
 				nt = reader.NodeType;
 			}
 
+			// Registers delayed list
+			
+			foreach (DictionaryEntry entry in delayedListFixups)
+				AddTarget ((string)entry.Key, entry.Value);
+			
 			// Fix arrays
 
 			if (collItemFixups != null)
@@ -871,7 +878,7 @@ namespace System.Xml.Serialization {
 			}
 		}
 
-		protected class CollectionItemFixup 
+		protected class CollectionItemFixup 
 		{
 			Array list;
 			int index;
@@ -884,17 +891,17 @@ namespace System.Xml.Serialization {
 				this.id = id;
 			}
 
-			public Array Collection
+			public Array Collection
 			{
 				get { return list; }
 			}
 
-			public int Index
+			public int Index
 			{
 				get { return index; }
 			}
 
-			public string Id
+			public string Id
 			{
 				get { return id; }
 			}

+ 29 - 29
mcs/class/System.XML/System.Xml.Serialization/XmlSerializationReaderInterpreter.cs

@@ -29,15 +29,15 @@ namespace System.Xml.Serialization
 			ArrayList maps = _typeMap.RelatedMaps;
 			if (maps != null)
 			{
-				foreach (XmlTypeMapping map in maps)  
+				foreach (XmlTypeMapping map in maps)  
 				{
 					if (map.TypeData.SchemaType == SchemaTypes.Class || map.TypeData.SchemaType == SchemaTypes.Enum)
 					{
 						ReaderCallbackInfo info = new ReaderCallbackInfo (this, map);
-						AddReadCallback (map.XmlType, map.Namespace, map.TypeData.Type, new XmlSerializationReadCallback (info.ReadObject));
-					}
-				}
-			}
+						AddReadCallback (map.XmlType, map.Namespace, map.TypeData.Type, new XmlSerializationReadCallback (info.ReadObject));
+					}
+				}
+			}
 		}
 
 		protected override void InitIDs ()
@@ -60,20 +60,20 @@ namespace System.Xml.Serialization
 
 		object ReadEncodedObject (XmlTypeMapping typeMap)
 		{
-			object ob = null;
-			Reader.MoveToContent();
-			if (Reader.NodeType == System.Xml.XmlNodeType.Element) 
-			{
-				if (Reader.LocalName == typeMap.ElementName && Reader.NamespaceURI == typeMap.Namespace)
-					ob = ReadReferencedElement();
-				else 
-					throw CreateUnknownNodeException();
-			}
-			else 
-				UnknownNode(null);
-
-			ReadReferencedElements();
-			return ob;
+			object ob = null;
+			Reader.MoveToContent();
+			if (Reader.NodeType == System.Xml.XmlNodeType.Element) 
+			{
+				if (Reader.LocalName == typeMap.ElementName && Reader.NamespaceURI == typeMap.Namespace)
+					ob = ReadReferencedElement();
+				else 
+					throw CreateUnknownNodeException();
+			}
+			else 
+				UnknownNode(null);
+
+			ReadReferencedElements();
+			return ob;
 		}
 
 		object ReadMessage (XmlMembersMapping typeMap)
@@ -102,8 +102,8 @@ namespace System.Xml.Serialization
 				ReadMembers ((ClassMap)typeMap.ObjectMap, parameters, true);
 
 			if (_format == SerializationFormat.Encoded)
-				ReadReferencedElements();
-
+				ReadReferencedElements();
+
 			return parameters;
 		}
 
@@ -219,8 +219,8 @@ namespace System.Xml.Serialization
 			if (_format == SerializationFormat.Encoded)
 			{
 				FixupCallbackInfo info = new FixupCallbackInfo (this, map, isValueList);
-				fixup = new Fixup(ob, new XmlSerializationFixupCallback(info.FixupMembers), map.ElementMembers.Count);
-				AddFixup (fixup);
+				fixup = new Fixup(ob, new XmlSerializationFixupCallback(info.FixupMembers), map.ElementMembers.Count);
+				AddFixup (fixup);
 			}
 
 			while (Reader.NodeType != System.Xml.XmlNodeType.EndElement) 
@@ -235,13 +235,13 @@ namespace System.Xml.Serialization
 							if (_format == SerializationFormat.Encoded && info.MultiReferenceType)
 							{
 								object list = ReadReferencingElement (out fixup.Ids[info.Member.Index]);
-								if (fixup.Ids[info.Member.Index] == null)	// Already read
+								if (fixup.Ids[info.Member.Index] == null)	// Already read
 								{
 									if (IsReadOnly (info.Member, ob, isValueList)) throw CreateReadOnlyCollectionException (info.TypeData.FullTypeName);
 									else SetMemberValue (info.Member, ob, list, isValueList);
-								}
-								else if (!info.MappedType.TypeData.Type.IsArray)
-								{
+								}
+								else if (!info.MappedType.TypeData.Type.IsArray)
+								{
 									if (IsReadOnly (info.Member, ob, isValueList)) 
 										list = GetMemberValue (info.Member, ob, isValueList);
 									else { 
@@ -250,7 +250,7 @@ namespace System.Xml.Serialization
 									}
 									AddFixup (new CollectionFixup (list, new XmlSerializationCollectionFixupCallback (FillList), fixup.Ids[info.Member.Index]));
 									fixup.Ids[info.Member.Index] = null;	// The member already has the value, no further fix needed.
-								}
+								}
 							}
 							else
 							{
@@ -274,7 +274,7 @@ namespace System.Xml.Serialization
 						{
 							object val;
 							readFlag[info.Member.Index] = true;
-							if (_format == SerializationFormat.Encoded && info.MultiReferenceType) 
+							if (_format == SerializationFormat.Encoded && info.MultiReferenceType) 
 							{
 								val = ReadReferencingElement (out fixup.Ids[info.Member.Index]);
 								if (fixup.Ids[info.Member.Index] == null)	// already read