global::System.Web.Services.Discovery.DiscoveryDocument Read9_DiscoveryDocument(bool isNullable, bool checkType)
        {
            System.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null;
            bool isNull = false;

            if (isNullable)
            {
                isNull = ReadNull();
            }
            if (checkType)
            {
                if (xsiType == null || ((object)((System.Xml.XmlQualifiedName)xsiType).Name == (object)id3_DiscoveryDocument && (object)((System.Xml.XmlQualifiedName)xsiType).Namespace == (object)id2_Item))
                {
                }
                else
                {
                    throw CreateUnknownTypeException((System.Xml.XmlQualifiedName)xsiType);
                }
            }
            if (isNull)
            {
                return(null);
            }
            global::System.Web.Services.Discovery.DiscoveryDocument o;
            o = new global::System.Web.Services.Discovery.DiscoveryDocument();
            global::System.Collections.IList a_0 = (global::System.Collections.IList)o.@References;
            bool[] paramsRead = new bool[1];
            while (Reader.MoveToNextAttribute())
            {
                if (!IsXmlnsAttribute(Reader.Name))
                {
                    UnknownNode((object)o);
                }
            }
            Reader.MoveToElement();
            if (Reader.IsEmptyElement)
            {
                Reader.Skip();
                return(o);
            }
            Reader.ReadStartElement();
            Reader.MoveToContent();
            int whileIterations0 = 0;
            int readerCount0     = ReaderCount;

            while (Reader.NodeType != System.Xml.XmlNodeType.EndElement && Reader.NodeType != System.Xml.XmlNodeType.None)
            {
                if (Reader.NodeType == System.Xml.XmlNodeType.Element)
                {
                    if (((object)Reader.LocalName == (object)id4_discoveryRef && (object)Reader.NamespaceURI == (object)id2_Item))
                    {
                        if ((object)(a_0) == null)
                        {
                            Reader.Skip();
                        }
                        else
                        {
                            a_0.Add(Read3_DiscoveryDocumentReference(false, true));
                        }
                    }
                    else if (((object)Reader.LocalName == (object)id5_contractRef && (object)Reader.NamespaceURI == (object)id6_Item))
                    {
                        if ((object)(a_0) == null)
                        {
                            Reader.Skip();
                        }
                        else
                        {
                            a_0.Add(Read5_ContractReference(false, true));
                        }
                    }
                    else if (((object)Reader.LocalName == (object)id7_schemaRef && (object)Reader.NamespaceURI == (object)id8_Item))
                    {
                        if ((object)(a_0) == null)
                        {
                            Reader.Skip();
                        }
                        else
                        {
                            a_0.Add(Read7_SchemaReference(false, true));
                        }
                    }
                    else if (((object)Reader.LocalName == (object)id9_soap && (object)Reader.NamespaceURI == (object)id10_Item))
                    {
                        if ((object)(a_0) == null)
                        {
                            Reader.Skip();
                        }
                        else
                        {
                            a_0.Add(Read8_SoapBinding(false, true));
                        }
                    }
                    else
                    {
                        UnknownNode((object)o, @"http://schemas.xmlsoap.org/disco/:discoveryRef, http://schemas.xmlsoap.org/disco/scl/:contractRef, http://schemas.xmlsoap.org/disco/schema/:schemaRef, http://schemas.xmlsoap.org/disco/soap/:soap");
                    }
                }
                else
                {
                    UnknownNode((object)o, @"http://schemas.xmlsoap.org/disco/:discoveryRef, http://schemas.xmlsoap.org/disco/scl/:contractRef, http://schemas.xmlsoap.org/disco/schema/:schemaRef, http://schemas.xmlsoap.org/disco/soap/:soap");
                }
                Reader.MoveToContent();
                CheckReaderCount(ref whileIterations0, ref readerCount0);
            }
            ReadEndElement();
            return(o);
        }
 global::System.Web.Services.Discovery.DiscoveryDocument Read9_DiscoveryDocument(bool isNullable, bool checkType) {
     System.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null;
     bool isNull = false;
     if (isNullable) isNull = ReadNull();
     if (checkType) {
     if (xsiType == null || ((object) ((System.Xml.XmlQualifiedName)xsiType).Name == (object)id3_DiscoveryDocument && (object) ((System.Xml.XmlQualifiedName)xsiType).Namespace == (object)id2_Item)) {
     }
     else
         throw CreateUnknownTypeException((System.Xml.XmlQualifiedName)xsiType);
     }
     if (isNull) return null;
     global::System.Web.Services.Discovery.DiscoveryDocument o;
     o = new global::System.Web.Services.Discovery.DiscoveryDocument();
     global::System.Collections.IList a_0 = (global::System.Collections.IList)o.@References;
     bool[] paramsRead = new bool[1];
     while (Reader.MoveToNextAttribute()) {
         if (!IsXmlnsAttribute(Reader.Name)) {
             UnknownNode((object)o);
         }
     }
     Reader.MoveToElement();
     if (Reader.IsEmptyElement) {
         Reader.Skip();
         return o;
     }
     Reader.ReadStartElement();
     Reader.MoveToContent();
     int whileIterations0 = 0;
     int readerCount0 = ReaderCount;
     while (Reader.NodeType != System.Xml.XmlNodeType.EndElement && Reader.NodeType != System.Xml.XmlNodeType.None) {
         if (Reader.NodeType == System.Xml.XmlNodeType.Element) {
             if (((object) Reader.LocalName == (object)id4_discoveryRef && (object) Reader.NamespaceURI == (object)id2_Item)) {
                 if ((object)(a_0) == null) Reader.Skip(); else a_0.Add(Read3_DiscoveryDocumentReference(false, true));
             }
             else if (((object) Reader.LocalName == (object)id5_contractRef && (object) Reader.NamespaceURI == (object)id6_Item)) {
                 if ((object)(a_0) == null) Reader.Skip(); else a_0.Add(Read5_ContractReference(false, true));
             }
             else if (((object) Reader.LocalName == (object)id7_schemaRef && (object) Reader.NamespaceURI == (object)id8_Item)) {
                 if ((object)(a_0) == null) Reader.Skip(); else a_0.Add(Read7_SchemaReference(false, true));
             }
             else if (((object) Reader.LocalName == (object)id9_soap && (object) Reader.NamespaceURI == (object)id10_Item)) {
                 if ((object)(a_0) == null) Reader.Skip(); else a_0.Add(Read8_SoapBinding(false, true));
             }
             else {
                 UnknownNode((object)o, @"http://schemas.xmlsoap.org/disco/:discoveryRef, http://schemas.xmlsoap.org/disco/scl/:contractRef, http://schemas.xmlsoap.org/disco/schema/:schemaRef, http://schemas.xmlsoap.org/disco/soap/:soap");
             }
         }
         else {
             UnknownNode((object)o, @"http://schemas.xmlsoap.org/disco/:discoveryRef, http://schemas.xmlsoap.org/disco/scl/:contractRef, http://schemas.xmlsoap.org/disco/schema/:schemaRef, http://schemas.xmlsoap.org/disco/soap/:soap");
         }
         Reader.MoveToContent();
         CheckReaderCount(ref whileIterations0, ref readerCount0);
     }
     ReadEndElement();
     return o;
 }
 void Write9_DiscoveryDocument(string n, string ns, global::System.Web.Services.Discovery.DiscoveryDocument o, bool isNullable, bool needType)
 {
     if ((object)o == null)
     {
         if (isNullable)
         {
             WriteNullTagLiteral(n, ns);
         }
         return;
     }
     if (!needType)
     {
         System.Type t = o.GetType();
         if (t == typeof(global::System.Web.Services.Discovery.DiscoveryDocument))
         {
         }
         else
         {
             throw CreateUnknownTypeException(o);
         }
     }
     WriteStartElement(n, ns, o, false, null);
     if (needType)
     {
         WriteXsiType(@"DiscoveryDocument", @"http://schemas.xmlsoap.org/disco/");
     }
     {
         global::System.Collections.IList a = (global::System.Collections.IList)o.@References;
         if (a != null)
         {
             for (int ia = 0; ia < ((System.Collections.ICollection)a).Count; ia++)
             {
                 global::System.Object ai = (global::System.Object)a[ia];
                 {
                     if (ai is global::System.Web.Services.Discovery.SchemaReference)
                     {
                         Write7_SchemaReference(@"schemaRef", @"http://schemas.xmlsoap.org/disco/schema/", ((global::System.Web.Services.Discovery.SchemaReference)ai), false, false);
                     }
                     else if (ai is global::System.Web.Services.Discovery.ContractReference)
                     {
                         Write5_ContractReference(@"contractRef", @"http://schemas.xmlsoap.org/disco/scl/", ((global::System.Web.Services.Discovery.ContractReference)ai), false, false);
                     }
                     else if (ai is global::System.Web.Services.Discovery.DiscoveryDocumentReference)
                     {
                         Write3_DiscoveryDocumentReference(@"discoveryRef", @"http://schemas.xmlsoap.org/disco/", ((global::System.Web.Services.Discovery.DiscoveryDocumentReference)ai), false, false);
                     }
                     else if (ai is global::System.Web.Services.Discovery.SoapBinding)
                     {
                         Write8_SoapBinding(@"soap", @"http://schemas.xmlsoap.org/disco/soap/", ((global::System.Web.Services.Discovery.SoapBinding)ai), false, false);
                     }
                     else
                     {
                         if (ai != null)
                         {
                             throw CreateUnknownTypeException(ai);
                         }
                     }
                 }
             }
         }
     }
     WriteEndElement(o);
 }