Exemplo n.º 1
0
 public override object ReadObject(System.Xml.XmlDictionaryReader reader, bool verifyObjectName)
 {
     if ((verifyObjectName == false))
     {
         throw new System.NotSupportedException();
     }
     if (this.info.IsWrapped)
     {
         // Some WSDLs incorrectly advertise their response message namespaces.
         // Attempt to interop with these by coercing our expected namespace to match.
         if ((this.serializer.CanDeserialize(reader) == false))
         {
             this.createSerializer(new System.Xml.XmlQualifiedName(System.Xml.XmlConvert.DecodeName(reader.LocalName), reader.NamespaceURI));
         }
         return(this.serializer.Deserialize(reader));
     }
     else
     {
         System.IO.MemoryStream       ms       = new System.IO.MemoryStream();
         System.Xml.XmlWriterSettings settings = new System.Xml.XmlWriterSettings();
         settings.OmitXmlDeclaration = true;
         System.Xml.XmlWriter innerWriter = System.Xml.XmlDictionaryWriter.Create(ms, settings);
         innerWriter.WriteStartElement(artificialWrapper.Name, artificialWrapper.Namespace);
         string[] commonPrefixes = new string[] {
             "xsi",
             "xsd"
         };
         for (int i = 0; (i < commonPrefixes.Length); i = (i + 1))
         {
             string ns = reader.LookupNamespace(commonPrefixes[i]);
             if ((ns != null))
             {
                 innerWriter.WriteAttributeString("xmlns", commonPrefixes[i], null, ns);
             }
         }
         for (
             ; ((reader.NodeType == System.Xml.XmlNodeType.EndElement)
                == false);
             )
         {
             innerWriter.WriteNode(reader, false);
         }
         innerWriter.WriteEndElement();
         innerWriter.Close();
         ms.Position = 0;
         System.Xml.XmlReader innerReader = System.Xml.XmlDictionaryReader.Create(ms);
         return(this.serializer.Deserialize(innerReader));
     }
 }