private void Write50_XmlSchemaKeyref(XmlSchemaKeyref o)
 {
     if (o != null)
     {
         o.GetType();
         this.WriteStartElement("keyref");
         this.WriteAttribute("id", "", o.Id);
         this.WriteAttribute("name", "", o.Name);
         this.WriteAttributes(o.UnhandledAttributes, o);
         this.WriteAttribute("refer", "", o.Refer);
         this.Write5_XmlSchemaAnnotation(o.Annotation);
         this.Write49_XmlSchemaXPath("selector", "", o.Selector);
         XmlSchemaObjectCollection fields = o.Fields;
         if (fields != null)
         {
             for (int i = 0; i < fields.Count; i++)
             {
                 this.Write49_XmlSchemaXPath("field", "", (XmlSchemaXPath) fields[i]);
             }
         }
         this.WriteEndElement();
     }
 }
 void Write50_XmlSchemaKeyref(XmlSchemaKeyref o) {
     if ((object)o == null) return;
     System.Type t = o.GetType();
     WriteStartElement("keyref");
     
     WriteAttribute(@"id", @"", ((System.String)o.@Id));
     WriteAttribute(@"name", @"", ((System.String)o.@Name));
     WriteAttributes((XmlAttribute[])o.@UnhandledAttributes, o);
     // 
     WriteAttribute(@"refer", @"", o.@Refer);
     Write5_XmlSchemaAnnotation((XmlSchemaAnnotation)o.@Annotation);
     Write49_XmlSchemaXPath(@"selector", @"", (XmlSchemaXPath)o.@Selector); {
     XmlSchemaObjectCollection a = (XmlSchemaObjectCollection)o.@Fields;
     if (a != null) {
         for (int ia = 0; ia < a.Count; ia++) {
             Write49_XmlSchemaXPath(@"field", @"", (XmlSchemaXPath)a[ia]);
         }
     }
 }
     WriteEndElement();
 }
 private void Write51_XmlSchemaKeyref(string n, string ns, XmlSchemaKeyref o, bool isNullable, bool needType)
 {
     if (o == null)
     {
         if (isNullable)
         {
             base.WriteNullTagLiteral(n, ns);
         }
     }
     else
     {
         if (!needType && !(o.GetType() == typeof(XmlSchemaKeyref)))
         {
             throw base.CreateUnknownTypeException(o);
         }
         base.EscapeName = false;
         base.WriteStartElement(n, ns, o, false, o.Namespaces);
         if (needType)
         {
             base.WriteXsiType("XmlSchemaKeyref", "http://www.w3.org/2001/XMLSchema");
         }
         base.WriteAttribute("id", "", o.Id);
         XmlAttribute[] unhandledAttributes = o.UnhandledAttributes;
         if (unhandledAttributes != null)
         {
             for (int i = 0; i < unhandledAttributes.Length; i++)
             {
                 XmlAttribute node = unhandledAttributes[i];
                 base.WriteXmlAttribute(node, o);
             }
         }
         base.WriteAttribute("name", "", o.Name);
         base.WriteAttribute("refer", "", base.FromXmlQualifiedName(o.Refer));
         this.Write11_XmlSchemaAnnotation("annotation", "http://www.w3.org/2001/XMLSchema", o.Annotation, false, false);
         this.Write47_XmlSchemaXPath("selector", "http://www.w3.org/2001/XMLSchema", o.Selector, false, false);
         XmlSchemaObjectCollection fields = o.Fields;
         if (fields != null)
         {
             for (int j = 0; j < fields.Count; j++)
             {
                 this.Write47_XmlSchemaXPath("field", "http://www.w3.org/2001/XMLSchema", (XmlSchemaXPath) fields[j], false, false);
             }
         }
         base.WriteEndElement(o);
     }
 }