Merge pull request #495 from nicolas-raoul/fix-for-issue2907-with-no-formatting-changes
authorMiguel de Icaza <miguel@gnome.org>
Fri, 7 Dec 2012 21:57:58 +0000 (13:57 -0800)
committerMiguel de Icaza <miguel@gnome.org>
Fri, 7 Dec 2012 21:57:58 +0000 (13:57 -0800)
Fix for issue 2907: XML "choice" not correctly processed during deserialization

1  2 
mcs/class/System.XML/System.Xml.Serialization/XmlTypeMapping.cs

index 859042fd7e34d404f8bcc489a1cd91c5b3fc500a,c23c5dd16c8994e894fe9813e1ae606a18dbd634..2b0f8bd829d2768ed76993523618639fae3e1f0c
@@@ -107,15 -107,10 +107,15 @@@ namespace System.Xml.Serializatio
  
                internal string XmlTypeNamespace
                {
 -                      get { return xmlTypeNamespace; }
 +                      get { return xmlTypeNamespace ?? string.Empty; }
                        set { xmlTypeNamespace = value; }
                }
  
 +              internal bool HasXmlTypeNamespace
 +              {
 +                      get { return xmlTypeNamespace != null; }
 +              }
 +
                internal ArrayList DerivedTypes
                {
                        get { return _derivedTypes; }
  
                internal XmlTypeMapping GetRealElementMap (string name, string ens)
                {
 -                      if (xmlType == name && xmlTypeNamespace == ens) return this;
 +                      if (xmlType == name && XmlTypeNamespace == ens) return this;
                        foreach (XmlTypeMapping map in _derivedTypes)
 -                              if (map.xmlType == name && map.xmlTypeNamespace == ens) return map;
 +                              if (map.xmlType == name && map.XmlTypeNamespace == ens) return map;
                        
                        return null;
                }
                        if (_elements == null) return null;
                        return (XmlTypeMapElementInfo)_elements [BuildKey (name,ns, order)];
                }
+               public XmlTypeMapElementInfo GetElement(string name, string ns)
+               {
+                       if (_elements == null) return null;
+                       foreach (XmlTypeMapElementInfo info in _elements.Values)
+                               if (info.ElementName == name && info.Namespace == ns)
+                                       return info;
+                       return null;
+               }
                
                public XmlTypeMapElementInfo GetElement (int index)
                {