public override bool Equals(object obj) { if (this == obj) { return(true); } if (!(obj is XmlTypeKey)) { return(false); } IXmlTypeKey other = (IXmlTypeKey)obj; return(Object.Equals(this.Name, other.Name) && Object.Equals(this.Namespace, other.Namespace)); }
public virtual bool WritesCustom(Object obj, Type type, IWriter writer) { if (!typeof(Type).IsAssignableFrom(type)) { return(false); } Type typeObj = (Type)obj; StringBuilder sb = null; while (typeObj.IsArray) { if (sb == null) { sb = new StringBuilder(); } sb.Append("[]"); typeObj = typeObj.GetElementType(); } String xmlName, xmlNamespace; IXmlTypeKey xmlType = XmlTypeRegistry.GetXmlType(typeObj); xmlName = xmlType.Name; xmlNamespace = xmlType.Namespace; int id = writer.AcquireIdForObject(obj); writer.WriteStartElement(XmlDictionary.ClassElement); writer.WriteAttribute(XmlDictionary.IdAttribute, id.ToString()); if (sb != null && sb.Length > 0) { sb.Insert(0, xmlName); writer.WriteAttribute(XmlDictionary.ClassNameAttribute, sb.ToString()); } else { writer.WriteAttribute(XmlDictionary.ClassNameAttribute, xmlName); } writer.WriteAttribute(XmlDictionary.ClassNamespaceAttribute, xmlNamespace); writer.WriteEndElement(); return(true); }