void Write3_Reference(string n, string ns, global::ExcelDna.Integration.Reference 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::ExcelDna.Integration.Reference))
         {
         }
         else
         {
             throw CreateUnknownTypeException(o);
         }
     }
     WriteStartElement(n, ns, o, false, null);
     if (needType)
     {
         WriteXsiType(null, @"");
     }
     WriteAttribute(@"AssemblyPath", @"", ((global::System.String)o.@AssemblyPath));
     WriteEndElement(o);
 }
 global::ExcelDna.Integration.Reference Read3_Reference(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)id2_Item && (object) ((System.Xml.XmlQualifiedName)xsiType).Namespace == (object)id2_Item)) {
     }
     else
         throw CreateUnknownTypeException((System.Xml.XmlQualifiedName)xsiType);
     }
     if (isNull) return null;
     global::ExcelDna.Integration.Reference o;
     o = new global::ExcelDna.Integration.Reference();
     bool[] paramsRead = new bool[4];
     while (Reader.MoveToNextAttribute()) {
         if (!paramsRead[0] && ((object) Reader.LocalName == (object)id3_Name && (object) Reader.NamespaceURI == (object)id2_Item)) {
             o.@Name = Reader.Value;
             paramsRead[0] = true;
         }
         else if (!paramsRead[1] && ((object) Reader.LocalName == (object)id18_AssemblyPath && (object) Reader.NamespaceURI == (object)id2_Item)) {
             o.@AssemblyPath = Reader.Value;
             paramsRead[1] = true;
         }
         else if (!paramsRead[2] && ((object) Reader.LocalName == (object)id17_Pack && (object) Reader.NamespaceURI == (object)id2_Item)) {
             o.@Pack = System.Xml.XmlConvert.ToBoolean(Reader.Value);
             paramsRead[2] = true;
         }
         else if (!paramsRead[3] && ((object) Reader.LocalName == (object)id16_Path && (object) Reader.NamespaceURI == (object)id2_Item)) {
             o.@Path = Reader.Value;
             paramsRead[3] = true;
         }
         else if (!IsXmlnsAttribute(Reader.Name)) {
             UnknownNode((object)o, @":Name, :AssemblyPath, :Pack, :Path");
         }
     }
     Reader.MoveToElement();
     if (Reader.IsEmptyElement) {
         Reader.Skip();
         return o;
     }
     Reader.ReadStartElement();
     Reader.MoveToContent();
     int whileIterations2 = 0;
     int readerCount2 = 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 whileIterations2, ref readerCount2);
     }
     ReadEndElement();
     return o;
 }
        global::ExcelDna.Integration.Reference Read3_Reference(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)id2_Item && (object)((System.Xml.XmlQualifiedName)xsiType).Namespace == (object)id2_Item))
                {
                }
                else
                {
                    throw CreateUnknownTypeException((System.Xml.XmlQualifiedName)xsiType);
                }
            }
            if (isNull)
            {
                return(null);
            }
            global::ExcelDna.Integration.Reference o;
            o = new global::ExcelDna.Integration.Reference();
            bool[] paramsRead = new bool[1];
            while (Reader.MoveToNextAttribute())
            {
                if (!paramsRead[0] && ((object)Reader.LocalName == (object)id10_AssemblyPath && (object)Reader.NamespaceURI == (object)id2_Item))
                {
                    o.@AssemblyPath = Reader.Value;
                    paramsRead[0]   = true;
                }
                else if (!IsXmlnsAttribute(Reader.Name))
                {
                    UnknownNode((object)o, @":AssemblyPath");
                }
            }
            Reader.MoveToElement();
            if (Reader.IsEmptyElement)
            {
                Reader.Skip();
                return(o);
            }
            Reader.ReadStartElement();
            Reader.MoveToContent();
            int whileIterations1 = 0;
            int readerCount1     = 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 whileIterations1, ref readerCount1);
            }
            ReadEndElement();
            return(o);
        }