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);
 }