protected static string ToXmlNmTokens(string value) { return(XmlCustomFormatter.ToXmlNmTokens(value)); }
protected static DateTime ToTime(string value) { return(XmlCustomFormatter.ToTime(value)); }
protected static string ToXmlNCName(string value) { return(XmlCustomFormatter.ToXmlNCName(value)); }
protected static char ToChar(string value) { return(XmlCustomFormatter.ToChar(value)); }
protected static long ToEnum(string value, Hashtable h, string typeName) { return(XmlCustomFormatter.ToEnum(value, h, typeName, true)); }
protected void WritePotentiallyReferencingElement(string n, string ns, object o, Type ambientType, bool suppressReference, bool isNullable) { if (o == null) { if (isNullable) { WriteNullTagEncoded(n, ns); } return; } WriteStartElement(n, ns, true); CheckReferenceQueue(); if (callbacks != null && callbacks.ContainsKey(o.GetType())) { WriteCallbackInfo info = (WriteCallbackInfo)callbacks[o.GetType()]; if (o.GetType().IsEnum) { info.Callback(o); } else if (suppressReference) { Writer.WriteAttributeString("id", GetId(o, false)); if (ambientType != o.GetType()) { WriteXsiType(info.TypeName, info.TypeNs); } info.Callback(o); } else { if (!AlreadyQueued(o)) { referencedElements.Enqueue(o); } Writer.WriteAttributeString("href", "#" + GetId(o, true)); } } else { // Must be a primitive type or array of primitives TypeData td = TypeTranslator.GetTypeData(o.GetType()); if (td.SchemaType == SchemaTypes.Primitive) { WriteXsiType(td.XmlType, XmlSchema.Namespace); Writer.WriteString(XmlCustomFormatter.ToXmlString(td, o)); } else if (IsPrimitiveArray(td)) { if (!AlreadyQueued(o)) { referencedElements.Enqueue(o); } Writer.WriteAttributeString("href", "#" + GetId(o, true)); } else { throw new InvalidOperationException("Invalid type: " + o.GetType().FullName); } } WriteEndElement(); }
void WriteStartElement(string name, string ns, object o, bool writePrefixed, ICollection namespaces) { if (o != null) { if (serializedObjects.Contains(o)) { throw new InvalidOperationException("A circular reference was detected while serializing an object of type " + o.GetType().Name); } else { serializedObjects [o] = o; } } string prefix = null; if (topLevelElement && ns != null && ns.Length != 0) { foreach (XmlQualifiedName qn in namespaces) { if (qn.Namespace == ns) { prefix = qn.Name; writePrefixed = true; break; } } } if (writePrefixed && ns != string.Empty) { name = XmlCustomFormatter.FromXmlName(name); if (prefix == null) { prefix = Writer.LookupPrefix(ns); } if (prefix == null || prefix.Length == 0) { prefix = "q" + (++qnameCount); } Writer.WriteStartElement(prefix, name, ns); } else { Writer.WriteStartElement(name, ns); } if (topLevelElement) { if (namespaces != null) { foreach (XmlQualifiedName qn in namespaces) { string currentPrefix = Writer.LookupPrefix(qn.Namespace); if (currentPrefix != null && currentPrefix.Length != 0) { continue; } WriteAttribute("xmlns", qn.Name, xmlNamespace, qn.Namespace); } } topLevelElement = false; } }
protected static string FromXmlNmTokens(string nmTokens) { return(XmlCustomFormatter.FromXmlNmTokens(nmTokens)); }
protected void WriteEmptyTag(string name, string ns) { name = XmlCustomFormatter.FromXmlName(name); WriteStartElement(name, ns); WriteEndElement(); }
protected static string FromXmlNCName(string ncName) { return(XmlCustomFormatter.FromXmlNCName(ncName)); }
protected static string FromTime(DateTime value) { return(XmlCustomFormatter.FromTime(value)); }
protected static string FromEnum(long value, string[] values, long[] ids) { return(XmlCustomFormatter.FromEnum(value, values, ids)); }
protected static string FromChar(char value) { return(XmlCustomFormatter.FromChar(value)); }
protected static string FromByteArrayHex(byte[] value) { return(XmlCustomFormatter.FromByteArrayHex(value)); }