2009-05-25 Atsushi Enomoto <atsushi@ximian.com>
authorAtsushi Eno <atsushieno@gmail.com>
Mon, 25 May 2009 08:14:58 +0000 (08:14 -0000)
committerAtsushi Eno <atsushieno@gmail.com>
Mon, 25 May 2009 08:14:58 +0000 (08:14 -0000)
* SerializationMap.cs, XmlFormatterSerializer.cs :
  collection types should not output xsi:type e.g. IList<T> should
  not exposed xsi:type as xsi:type=List`1.

svn path=/trunk/mcs/; revision=134670

mcs/class/System.Runtime.Serialization/System.Runtime.Serialization/ChangeLog
mcs/class/System.Runtime.Serialization/System.Runtime.Serialization/SerializationMap.cs
mcs/class/System.Runtime.Serialization/System.Runtime.Serialization/XmlFormatterSerializer.cs

index 8d759ce83ce3afe515d224946ae1262bb3694ed5..35c0b0e7baa25e433a94debde79a13c1bbb8c35a 100755 (executable)
@@ -1,3 +1,9 @@
+2009-05-25  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * SerializationMap.cs, XmlFormatterSerializer.cs :
+         collection types should not output xsi:type e.g. IList<T> should
+         not exposed xsi:type as xsi:type=List`1.
+
 2009-05-18  Atsushi Enomoto  <atsushi@ximian.com>
 
        * SerializationMap.cs, XmlFormatterDeserializer.cs,
index ce1638ea5c6dfedd2cf2095bdff97fb1e31e1027..fd6416066762942aeaaaa804a70256c8a406a8fc 100644 (file)
@@ -108,6 +108,10 @@ namespace System.Runtime.Serialization
                        Members = new List<DataMemberInfo> ();
                }
 
+               public virtual bool OutputXsiType {
+                       get { return true; }
+               }
+
                public QName XmlName { get; set; }
 
                public CollectionDataContractAttribute GetCollectionDataContractAttribute (Type type)
@@ -589,6 +593,10 @@ namespace System.Runtime.Serialization
                        }
                }
 
+               public override bool OutputXsiType {
+                       get { return false; }
+               }
+
                internal virtual string CurrentNamespace {
                        get {
                                string ns = element_qname.Namespace;
index a3364899e6db8ef892478312d4b1f4fbe2a63eed..bdcca7441d6aaed9c2297fddc31e4332fe63bc13 100644 (file)
@@ -88,7 +88,15 @@ namespace System.Runtime.Serialization
                                writer.WriteAttributeString ("nil", XmlSchema.InstanceNamespace, "true");
                        else {
                                Type actualType = graph.GetType ();
-                               if (actualType != type) {
+
+                               SerializationMap map = types.FindUserMap (actualType);
+                               if (map == null) {
+                                       /* Unknown actual type */
+                                       types.Add (actualType);
+                                       map = types.FindUserMap (actualType);
+                               }
+
+                               if (actualType != type && (map == null || map.OutputXsiType)) {
                                        QName qname = types.GetXmlName (actualType);
                                        string name = qname.Name;
                                        string ns = qname.Namespace;
@@ -107,7 +115,7 @@ namespace System.Runtime.Serialization
                                if (predef != QName.Empty)
                                        SerializePrimitive (type, graph, predef);
                                else
-                                       SerializeNonPrimitive (type, graph);
+                                       map.Serialize (graph, this);
                        }
                }
 
@@ -130,20 +138,6 @@ namespace System.Runtime.Serialization
                {
                        writer.WriteEndElement ();
                }
-
-               public void SerializeNonPrimitive (Type type, object graph)
-               {
-                       Type actualType = graph.GetType ();
-
-                       SerializationMap map = types.FindUserMap (actualType);
-                       if (map == null) {
-                               /* Unknown actual type */
-                               types.Add (actualType);
-                               map = types.FindUserMap (actualType);
-                       }
-
-                       map.Serialize (graph, this);
-               }
        }
 }
 #endif