void Write5_ContractReference(string n, string ns, global::System.Web.Services.Discovery.ContractReference 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.ContractReference))
         {
         }
         else
         {
             throw CreateUnknownTypeException(o);
         }
     }
     WriteStartElement(n, ns, o, false, null);
     if (needType)
     {
         WriteXsiType(@"ContractReference", @"http://schemas.xmlsoap.org/disco/scl/");
     }
     WriteAttribute(@"ref", @"", ((global::System.String)o.@Ref));
     WriteAttribute(@"docRef", @"", ((global::System.String)o.@DocRef));
     WriteEndElement(o);
 }
 global::System.Web.Services.Discovery.ContractReference Read5_ContractReference(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)id18_ContractReference && (object) ((System.Xml.XmlQualifiedName)xsiType).Namespace == (object)id6_Item)) {
     }
     else
         throw CreateUnknownTypeException((System.Xml.XmlQualifiedName)xsiType);
     }
     if (isNull) return null;
     global::System.Web.Services.Discovery.ContractReference o;
     o = new global::System.Web.Services.Discovery.ContractReference();
     bool[] paramsRead = new bool[2];
     while (Reader.MoveToNextAttribute()) {
         if (!paramsRead[0] && ((object) Reader.LocalName == (object)id16_ref && (object) Reader.NamespaceURI == (object)id13_Item)) {
             o.@Ref = Reader.Value;
             paramsRead[0] = true;
         }
         else if (!paramsRead[1] && ((object) Reader.LocalName == (object)id19_docRef && (object) Reader.NamespaceURI == (object)id13_Item)) {
             o.@DocRef = Reader.Value;
             paramsRead[1] = true;
         }
         else if (!IsXmlnsAttribute(Reader.Name)) {
             UnknownNode((object)o, @":ref, :docRef");
         }
     }
     Reader.MoveToElement();
     if (Reader.IsEmptyElement) {
         Reader.Skip();
         return o;
     }
     Reader.ReadStartElement();
     Reader.MoveToContent();
     int whileIterations3 = 0;
     int readerCount3 = ReaderCount;
     while (Reader.NodeType != System.Xml.XmlNodeType.EndElement && Reader.NodeType != System.Xml.XmlNodeType.None) {
         if (Reader.NodeType == System.Xml.XmlNodeType.Element) {
             UnknownNode((object)o, @"");
         }
         else {
             UnknownNode((object)o, @"");
         }
         Reader.MoveToContent();
         CheckReaderCount(ref whileIterations3, ref readerCount3);
     }
     ReadEndElement();
     return o;
 }
        global::System.Web.Services.Discovery.ContractReference Read5_ContractReference(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)id18_ContractReference && (object)((System.Xml.XmlQualifiedName)xsiType).Namespace == (object)id6_Item))
                {
                }
                else
                {
                    throw CreateUnknownTypeException((System.Xml.XmlQualifiedName)xsiType);
                }
            }
            if (isNull)
            {
                return(null);
            }
            global::System.Web.Services.Discovery.ContractReference o;
            o = new global::System.Web.Services.Discovery.ContractReference();
            bool[] paramsRead = new bool[2];
            while (Reader.MoveToNextAttribute())
            {
                if (!paramsRead[0] && ((object)Reader.LocalName == (object)id16_ref && (object)Reader.NamespaceURI == (object)id13_Item))
                {
                    o.@Ref        = Reader.Value;
                    paramsRead[0] = true;
                }
                else if (!paramsRead[1] && ((object)Reader.LocalName == (object)id19_docRef && (object)Reader.NamespaceURI == (object)id13_Item))
                {
                    o.@DocRef     = Reader.Value;
                    paramsRead[1] = true;
                }
                else if (!IsXmlnsAttribute(Reader.Name))
                {
                    UnknownNode((object)o, @":ref, :docRef");
                }
            }
            Reader.MoveToElement();
            if (Reader.IsEmptyElement)
            {
                Reader.Skip();
                return(o);
            }
            Reader.ReadStartElement();
            Reader.MoveToContent();
            int whileIterations3 = 0;
            int readerCount3     = ReaderCount;

            while (Reader.NodeType != System.Xml.XmlNodeType.EndElement && Reader.NodeType != System.Xml.XmlNodeType.None)
            {
                if (Reader.NodeType == System.Xml.XmlNodeType.Element)
                {
                    UnknownNode((object)o, @"");
                }
                else
                {
                    UnknownNode((object)o, @"");
                }
                Reader.MoveToContent();
                CheckReaderCount(ref whileIterations3, ref readerCount3);
            }
            ReadEndElement();
            return(o);
        }