2 // System.Xml.Serialization.XmlSerializationWriter.cs
5 // Tim Coleman (tim@timcoleman.com)
6 // Lluis Sanchez Gual (lluis@ximian.com)
8 // Copyright (C) Tim Coleman, 2002
12 // Permission is hereby granted, free of charge, to any person obtaining
13 // a copy of this software and associated documentation files (the
14 // "Software"), to deal in the Software without restriction, including
15 // without limitation the rights to use, copy, modify, merge, publish,
16 // distribute, sublicense, and/or sell copies of the Software, and to
17 // permit persons to whom the Software is furnished to do so, subject to
18 // the following conditions:
20 // The above copyright notice and this permission notice shall be
21 // included in all copies or substantial portions of the Software.
23 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
24 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
25 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
26 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
27 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
28 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
29 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
33 using System.Collections;
34 using System.Collections.Generic;
35 using System.Globalization;
38 using System.Xml.Schema;
39 using System.Runtime.Serialization;
40 using System.Reflection;
42 namespace System.Xml.Serialization
44 public abstract class XmlSerializationWriter
46 : XmlSerializationGeneratedCode
52 ObjectIDGenerator idGenerator;
54 bool topLevelElement = false;
58 Queue referencedElements;
60 Hashtable serializedObjects;
61 const string xmlNamespace = "http://www.w3.org/2000/xmlns/";
62 const string unexpectedTypeError = "The type {0} was not expected. Use the" +
63 " XmlInclude or SoapInclude attribute to specify types that are not known statically.";
69 protected XmlSerializationWriter ()
72 serializedObjects = new Hashtable ();
75 internal void Initialize (XmlWriter writer, XmlSerializerNamespaces nss)
80 namespaces = new ArrayList ();
81 foreach (XmlQualifiedName ns in nss.ToArray())
82 if (ns.Name != "" && ns.Namespace != "")
87 #endregion // Constructors
91 protected ArrayList Namespaces {
92 get { return namespaces; }
93 set { namespaces = value; }
96 protected XmlWriter Writer {
97 get { return writer; }
98 set { writer = value; }
101 #endregion // Properties
105 protected void AddWriteCallback (Type type, string typeName, string typeNs, XmlSerializationWriteCallback callback)
107 WriteCallbackInfo info = new WriteCallbackInfo ();
109 info.TypeName = typeName;
110 info.TypeNs = typeNs;
111 info.Callback = callback;
113 if (callbacks == null) callbacks = new Hashtable ();
114 callbacks.Add (type, info);
117 protected Exception CreateChoiceIdentifierValueException (string value, string identifier, string name, string ns)
119 string message = string.Format ("Value '{0}' of the choice"
120 + " identifier '{1}' does not match element '{2}'"
121 + " from namespace '{3}'.", value, identifier,
123 return new InvalidOperationException (message);
126 protected Exception CreateInvalidChoiceIdentifierValueException (string type, string identifier)
128 string message = string.Format ("Invalid or missing choice"
129 + " identifier '{0}' of type '{1}'.", identifier,
131 return new InvalidOperationException (message);
134 protected Exception CreateMismatchChoiceException (string value, string elementName, string enumValue)
136 string message = String.Format ("Value of {0} mismatches the type of {1}, you need to set it to {2}.", elementName, value, enumValue);
137 return new InvalidOperationException (message);
140 protected Exception CreateUnknownAnyElementException (string name, string ns)
142 string message = String.Format ("The XML element named '{0}' from namespace '{1}' was not expected. The XML element name and namespace must match those provided via XmlAnyElementAttribute(s).", name, ns);
143 return new InvalidOperationException (message);
146 protected Exception CreateUnknownTypeException (object o)
148 return CreateUnknownTypeException (o.GetType ());
151 protected Exception CreateUnknownTypeException (Type type)
153 string message = String.Format ("The type {0} may not be used in this context.", type);
154 return new InvalidOperationException (message);
157 protected static byte[] FromByteArrayBase64 (byte[] value)
162 protected static string FromByteArrayHex (byte[] value)
164 return XmlCustomFormatter.FromByteArrayHex (value);
167 protected static string FromChar (char value)
169 return XmlCustomFormatter.FromChar (value);
172 protected static string FromDate (DateTime value)
174 return XmlCustomFormatter.FromDate (value);
177 protected static string FromDateTime (DateTime value)
179 return XmlCustomFormatter.FromDateTime (value);
182 protected static string FromEnum (long value, string[] values, long[] ids)
184 return XmlCustomFormatter.FromEnum (value, values, ids);
187 protected static string FromTime (DateTime value)
189 return XmlCustomFormatter.FromTime (value);
192 protected static string FromXmlName (string name)
194 return XmlCustomFormatter.FromXmlName (name);
197 protected static string FromXmlNCName (string ncName)
199 return XmlCustomFormatter.FromXmlNCName (ncName);
202 protected static string FromXmlNmToken (string nmToken)
204 return XmlCustomFormatter.FromXmlNmToken (nmToken);
207 protected static string FromXmlNmTokens (string nmTokens)
209 return XmlCustomFormatter.FromXmlNmTokens (nmTokens);
212 protected string FromXmlQualifiedName (XmlQualifiedName xmlQualifiedName)
214 if (xmlQualifiedName == null || xmlQualifiedName == XmlQualifiedName.Empty)
217 return GetQualifiedName (xmlQualifiedName.Name, xmlQualifiedName.Namespace);
220 private string GetId (object o, bool addToReferencesList)
222 if (idGenerator == null) idGenerator = new ObjectIDGenerator ();
225 long lid = idGenerator.GetId (o, out firstTime);
226 return String.Format (CultureInfo.InvariantCulture, "id{0}", lid);
230 bool AlreadyQueued (object ob)
232 if (idGenerator == null) return false;
235 idGenerator.HasId (ob, out firstTime);
239 private string GetNamespacePrefix (string ns)
241 string prefix = Writer.LookupPrefix (ns);
244 prefix = String.Format (CultureInfo.InvariantCulture, "q{0}", ++qnameCount);
245 WriteAttribute ("xmlns", prefix, null, ns);
250 private string GetQualifiedName (string name, string ns)
252 if (ns == String.Empty) return name;
254 string prefix = GetNamespacePrefix (ns);
255 if (prefix == String.Empty)
258 return String.Format ("{0}:{1}", prefix, name);
261 protected abstract void InitCallbacks ();
263 protected void TopLevelElement ()
265 topLevelElement = true;
268 protected void WriteAttribute (string localName, byte[] value)
270 WriteAttribute (localName, String.Empty, value);
273 protected void WriteAttribute (string localName, string value)
275 WriteAttribute (String.Empty, localName, String.Empty, value);
278 protected void WriteAttribute (string localName, string ns, byte[] value)
283 Writer.WriteStartAttribute (localName, ns);
285 Writer.WriteEndAttribute ();
288 protected void WriteAttribute (string localName, string ns, string value)
290 WriteAttribute (null, localName, ns, value);
293 protected void WriteAttribute (string prefix, string localName, string ns, string value)
298 Writer.WriteAttributeString (prefix, localName, ns, value);
301 void WriteXmlNode (XmlNode node)
303 if (node is XmlDocument)
304 node = ((XmlDocument) node).DocumentElement;
306 node.WriteTo (Writer);
309 protected void WriteElementEncoded (XmlNode node, string name, string ns, bool isNullable, bool any)
311 if (name != string.Empty)
316 WriteNullTagEncoded (name, ns);
320 Writer.WriteStartElement (name, ns);
322 Writer.WriteEndElement ();
329 protected void WriteElementLiteral (XmlNode node, string name, string ns, bool isNullable, bool any)
331 if (name != string.Empty)
336 WriteNullTagLiteral (name, ns);
340 Writer.WriteStartElement (name, ns);
342 Writer.WriteEndElement ();
349 protected void WriteElementQualifiedName (string localName, XmlQualifiedName value)
351 WriteElementQualifiedName (localName, String.Empty, value, null);
354 protected void WriteElementQualifiedName (string localName, string ns, XmlQualifiedName value)
356 WriteElementQualifiedName (localName, ns, value, null);
359 protected void WriteElementQualifiedName (string localName, XmlQualifiedName value, XmlQualifiedName xsiType)
361 WriteElementQualifiedName (localName, String.Empty, value, xsiType);
364 protected void WriteElementQualifiedName (string localName, string ns, XmlQualifiedName value, XmlQualifiedName xsiType)
366 localName = XmlCustomFormatter.FromXmlNCName (localName);
367 WriteStartElement (localName, ns);
368 if (xsiType != null) WriteXsiType (xsiType.Name, xsiType.Namespace);
369 Writer.WriteString (FromXmlQualifiedName (value));
373 protected void WriteElementString (string localName, string value)
375 WriteElementString (localName, String.Empty, value, null);
378 protected void WriteElementString (string localName, string ns, string value)
380 WriteElementString (localName, ns, value, null);
383 protected void WriteElementString (string localName, string value, XmlQualifiedName xsiType)
385 WriteElementString (localName, String.Empty, value, xsiType);
388 protected void WriteElementString (string localName, string ns, string value, XmlQualifiedName xsiType)
390 if (value == null) return;
392 if (xsiType != null) {
393 localName = XmlCustomFormatter.FromXmlNCName (localName);
394 WriteStartElement (localName, ns);
395 WriteXsiType (xsiType.Name, xsiType.Namespace);
396 Writer.WriteString (value);
400 Writer.WriteElementString (localName, ns, value);
403 protected void WriteElementStringRaw (string localName, byte[] value)
405 WriteElementStringRaw (localName, String.Empty, value, null);
408 protected void WriteElementStringRaw (string localName, string value)
410 WriteElementStringRaw (localName, String.Empty, value, null);
413 protected void WriteElementStringRaw (string localName, byte[] value, XmlQualifiedName xsiType)
415 WriteElementStringRaw (localName, String.Empty, value, xsiType);
418 protected void WriteElementStringRaw (string localName, string ns, byte[] value)
420 WriteElementStringRaw (localName, ns, value, null);
423 protected void WriteElementStringRaw (string localName, string ns, string value)
425 WriteElementStringRaw (localName, ns, value, null);
428 protected void WriteElementStringRaw (string localName, string value, XmlQualifiedName xsiType)
430 WriteElementStringRaw (localName, String.Empty, value, null);
433 protected void WriteElementStringRaw (string localName, string ns, byte[] value, XmlQualifiedName xsiType)
438 WriteStartElement (localName, ns);
441 WriteXsiType (xsiType.Name, xsiType.Namespace);
443 if (value.Length > 0)
444 Writer.WriteBase64(value,0,value.Length);
448 protected void WriteElementStringRaw (string localName, string ns, string value, XmlQualifiedName xsiType)
450 localName = XmlCustomFormatter.FromXmlNCName (localName);
451 WriteStartElement (localName, ns);
454 WriteXsiType (xsiType.Name, xsiType.Namespace);
456 Writer.WriteRaw (value);
460 protected void WriteEmptyTag (string name)
462 WriteEmptyTag (name, String.Empty);
465 protected void WriteEmptyTag (string name, string ns)
467 name = XmlCustomFormatter.FromXmlName (name);
468 WriteStartElement (name, ns);
472 protected void WriteEndElement ()
474 WriteEndElement (null);
477 protected void WriteEndElement (object o)
480 serializedObjects.Remove (o);
482 Writer.WriteEndElement ();
485 protected void WriteId (object o)
487 WriteAttribute ("id", GetId (o, true));
490 protected void WriteNamespaceDeclarations (XmlSerializerNamespaces xmlns)
494 ICollection namespaces = xmlns.Namespaces.Values;
495 foreach (XmlQualifiedName qn in namespaces) {
496 if (qn.Namespace != String.Empty && Writer.LookupPrefix (qn.Namespace) != qn.Name)
497 WriteAttribute ("xmlns", qn.Name, xmlNamespace, qn.Namespace);
501 protected void WriteNullableQualifiedNameEncoded (string name, string ns, XmlQualifiedName value, XmlQualifiedName xsiType)
504 WriteElementQualifiedName (name, ns, value, xsiType);
506 WriteNullTagEncoded (name, ns);
509 protected void WriteNullableQualifiedNameLiteral (string name, string ns, XmlQualifiedName value)
512 WriteElementQualifiedName (name, ns, value);
514 WriteNullTagLiteral (name, ns);
517 protected void WriteNullableStringEncoded (string name, string ns, string value, XmlQualifiedName xsiType)
520 WriteElementString (name, ns, value, xsiType);
522 WriteNullTagEncoded (name, ns);
525 protected void WriteNullableStringEncodedRaw (string name, string ns, byte[] value, XmlQualifiedName xsiType)
528 WriteNullTagEncoded (name, ns);
530 WriteElementStringRaw (name, ns, value, xsiType);
533 protected void WriteNullableStringEncodedRaw (string name, string ns, string value, XmlQualifiedName xsiType)
536 WriteNullTagEncoded (name, ns);
538 WriteElementStringRaw (name, ns, value, xsiType);
541 protected void WriteNullableStringLiteral (string name, string ns, string value)
544 WriteElementString (name, ns, value, null);
546 WriteNullTagLiteral (name, ns);
549 protected void WriteNullableStringLiteralRaw (string name, string ns, byte[] value)
552 WriteNullTagLiteral (name, ns);
554 WriteElementStringRaw (name, ns, value);
557 protected void WriteNullableStringLiteralRaw (string name, string ns, string value)
560 WriteNullTagLiteral (name, ns);
562 WriteElementStringRaw (name, ns, value);
565 protected void WriteNullTagEncoded (string name)
567 WriteNullTagEncoded (name, String.Empty);
570 protected void WriteNullTagEncoded (string name, string ns)
572 Writer.WriteStartElement (name, ns);
573 Writer.WriteAttributeString ("nil", XmlSchema.InstanceNamespace, "true");
574 Writer.WriteEndElement ();
577 protected void WriteNullTagLiteral (string name)
579 WriteNullTagLiteral (name, String.Empty);
582 protected void WriteNullTagLiteral (string name, string ns)
584 WriteStartElement (name, ns);
585 Writer.WriteAttributeString ("nil", XmlSchema.InstanceNamespace, "true");
589 protected void WritePotentiallyReferencingElement (string n, string ns, object o)
591 WritePotentiallyReferencingElement (n, ns, o, null, false, false);
594 protected void WritePotentiallyReferencingElement (string n, string ns, object o, Type ambientType)
596 WritePotentiallyReferencingElement (n, ns, o, ambientType, false, false);
599 protected void WritePotentiallyReferencingElement (string n, string ns, object o, Type ambientType, bool suppressReference)
601 WritePotentiallyReferencingElement (n, ns, o, ambientType, suppressReference, false);
604 protected void WritePotentiallyReferencingElement (string n, string ns, object o, Type ambientType, bool suppressReference, bool isNullable)
608 if (isNullable) WriteNullTagEncoded (n, ns);
612 var t = o.GetType ();
614 WriteStartElement (n, ns, true);
616 CheckReferenceQueue ();
618 if (callbacks != null && callbacks.ContainsKey (o.GetType ()))
620 WriteCallbackInfo info = (WriteCallbackInfo) callbacks[t];
624 else if (suppressReference) {
625 Writer.WriteAttributeString ("id", GetId (o, false));
626 if (ambientType != t) WriteXsiType(info.TypeName, info.TypeNs);
630 if (!AlreadyQueued (o)) referencedElements.Enqueue (o);
631 Writer.WriteAttributeString ("href", "#" + GetId (o, true));
636 // Must be a primitive type or array of primitives
637 TypeData td = TypeTranslator.GetTypeData (t, null, true);
638 if (td.SchemaType == SchemaTypes.Primitive) {
639 if (t != ambientType)
640 WriteXsiType (td.XmlType, XmlSchema.Namespace);
641 Writer.WriteString (XmlCustomFormatter.ToXmlString (td, o));
642 } else if (IsPrimitiveArray (td)) {
643 if (!AlreadyQueued (o)) referencedElements.Enqueue (o);
644 Writer.WriteAttributeString ("href", "#" + GetId (o, true));
646 throw new InvalidOperationException ("Invalid type: " + t.FullName);
653 protected void WriteReferencedElements ()
655 if (referencedElements == null) return;
656 if (callbacks == null) return;
658 while (referencedElements.Count > 0)
660 object o = referencedElements.Dequeue ();
661 TypeData td = TypeTranslator.GetTypeData (o.GetType ());
662 WriteCallbackInfo info = (WriteCallbackInfo) callbacks[o.GetType()];
665 WriteStartElement (info.TypeName, info.TypeNs, true);
666 Writer.WriteAttributeString ("id", GetId (o, false));
668 if (td.SchemaType != SchemaTypes.Array) // Array use its own "arrayType" attribute
669 WriteXsiType(info.TypeName, info.TypeNs);
673 } else if (IsPrimitiveArray (td)) {
679 bool IsPrimitiveArray (TypeData td)
681 if (td.SchemaType == SchemaTypes.Array) {
682 if (td.ListItemTypeData.SchemaType == SchemaTypes.Primitive || td.ListItemType == typeof(object))
684 return IsPrimitiveArray (td.ListItemTypeData);
689 void WriteArray (object o, TypeData td)
691 TypeData itemTypeData = td;
696 itemTypeData = itemTypeData.ListItemTypeData;
697 xmlType = itemTypeData.XmlType;
700 while (itemTypeData.SchemaType == SchemaTypes.Array );
705 WriteStartElement("Array", XmlSerializer.EncodingNamespace, true);
706 Writer.WriteAttributeString("id", GetId(o, false));
707 if (td.SchemaType == SchemaTypes.Array) {
710 Writer.WriteAttributeString("arrayType", XmlSerializer.EncodingNamespace, GetQualifiedName(xmlType, XmlSchema.Namespace) + "[" + len.ToString() + "]");
711 for (int i = 0; i < len; i++) {
712 WritePotentiallyReferencingElement("Item", "", a.GetValue(i), td.ListItemType, false, true);
719 protected void WriteReferencingElement (string n, string ns, object o)
721 WriteReferencingElement (n, ns, o, false);
724 protected void WriteReferencingElement (string n, string ns, object o, bool isNullable)
728 if (isNullable) WriteNullTagEncoded (n, ns);
733 CheckReferenceQueue ();
734 if (!AlreadyQueued (o)) referencedElements.Enqueue (o);
736 Writer.WriteStartElement (n, ns);
737 Writer.WriteAttributeString ("href", "#" + GetId (o, true));
738 Writer.WriteEndElement ();
742 void CheckReferenceQueue ()
744 if (referencedElements == null)
746 referencedElements = new Queue ();
752 protected void WriteRpcResult (string name, string ns)
754 throw new NotImplementedException ();
757 protected void WriteSerializable (IXmlSerializable serializable, string name, string ns, bool isNullable)
759 WriteSerializable (serializable, name, ns, isNullable, true);
765 void WriteSerializable (IXmlSerializable serializable, string name, string ns, bool isNullable, bool wrapped)
767 if (serializable == null)
769 if (isNullable && wrapped) WriteNullTagLiteral (name, ns);
775 Writer.WriteStartElement (name, ns);
776 serializable.WriteXml (Writer);
778 Writer.WriteEndElement ();
782 protected void WriteStartDocument ()
784 if (Writer.WriteState == WriteState.Start)
785 Writer.WriteStartDocument ();
788 protected void WriteStartElement (string name)
790 WriteStartElement (name, String.Empty, null, false);
793 protected void WriteStartElement (string name, string ns)
795 WriteStartElement (name, ns, null, false);
798 protected void WriteStartElement (string name, string ns, bool writePrefixed)
800 WriteStartElement (name, ns, null, writePrefixed);
803 protected void WriteStartElement (string name, string ns, object o)
805 WriteStartElement (name, ns, o, false);
808 protected void WriteStartElement (string name, string ns, object o, bool writePrefixed)
810 WriteStartElement (name, ns, o, writePrefixed, namespaces);
814 protected void WriteStartElement (string name, string ns, Object o, bool writePrefixed, XmlSerializerNamespaces xmlns)
816 WriteStartElement (name, ns, o, writePrefixed, xmlns != null ? xmlns.ToArray () : null);
820 void WriteStartElement (string name, string ns, object o, bool writePrefixed, ICollection namespaces)
824 if (serializedObjects.Contains (o))
825 throw new InvalidOperationException ("A circular reference was detected while serializing an object of type " + o.GetType().Name);
827 serializedObjects [o] = o;
830 string prefix = null;
832 if (topLevelElement && ns != null && ns.Length != 0)
834 if (namespaces != null)
835 foreach (XmlQualifiedName qn in namespaces)
836 if (qn.Namespace == ns) {
838 writePrefixed = true;
843 if (writePrefixed && ns != string.Empty)
845 name = XmlCustomFormatter.FromXmlName (name);
848 prefix = Writer.LookupPrefix (ns);
849 if (prefix == null || prefix.Length == 0)
850 prefix = "q" + (++qnameCount);
851 Writer.WriteStartElement (prefix, name, ns);
853 Writer.WriteStartElement (name, ns);
857 if (namespaces != null) {
858 foreach (XmlQualifiedName qn in namespaces)
860 string currentPrefix = Writer.LookupPrefix (qn.Namespace);
861 if (currentPrefix != null && currentPrefix.Length != 0) continue;
863 WriteAttribute ("xmlns",qn.Name,xmlNamespace,qn.Namespace);
866 topLevelElement = false;
870 protected void WriteTypedPrimitive (string name, string ns, object o, bool xsiType)
873 TypeData td = TypeTranslator.GetTypeData (o.GetType (), null, true);
874 if (td.SchemaType != SchemaTypes.Primitive)
875 throw new InvalidOperationException (String.Format ("The type of the argument object '{0}' is not primitive.", td.FullTypeName));
878 ns = td.IsXsdType ? XmlSchema.Namespace : XmlSerializer.WsdlTypesNamespace;
882 name = XmlCustomFormatter.FromXmlName (name);
883 Writer.WriteStartElement (name, ns);
885 if (o is XmlQualifiedName)
886 value = FromXmlQualifiedName ((XmlQualifiedName) o);
888 value = XmlCustomFormatter.ToXmlString (td, o);
892 if (td.SchemaType != SchemaTypes.Primitive)
893 throw new InvalidOperationException (string.Format (unexpectedTypeError, o.GetType().FullName));
894 WriteXsiType (td.XmlType, td.IsXsdType ? XmlSchema.Namespace : XmlSerializer.WsdlTypesNamespace);
899 Writer.WriteEndElement ();
902 protected void WriteValue (byte[] value)
904 Writer.WriteBase64 (value, 0, value.Length);
907 protected void WriteValue (string value)
910 Writer.WriteString (value);
913 protected void WriteXmlAttribute (XmlNode node)
915 WriteXmlAttribute (node, null);
918 protected void WriteXmlAttribute (XmlNode node, object container)
920 XmlAttribute attr = node as XmlAttribute;
922 throw new InvalidOperationException ("The node must be either type XmlAttribute or a derived type.");
924 if (attr.NamespaceURI == XmlSerializer.WsdlNamespace)
926 // The wsdl arrayType attribute needs special handling
927 if (attr.LocalName == "arrayType") {
928 string ns, type, dimensions;
929 TypeTranslator.ParseArrayType (attr.Value, out type, out ns, out dimensions);
930 string value = GetQualifiedName (type + dimensions, ns);
931 WriteAttribute (attr.Prefix, attr.LocalName, attr.NamespaceURI, value);
936 WriteAttribute (attr.Prefix, attr.LocalName, attr.NamespaceURI, attr.Value);
939 protected void WriteXsiType (string name, string ns)
941 if (ns != null && ns != string.Empty)
942 WriteAttribute ("type", XmlSchema.InstanceNamespace, GetQualifiedName (name, ns));
944 WriteAttribute ("type", XmlSchema.InstanceNamespace, name);
949 protected Exception CreateInvalidAnyTypeException (object o)
952 return new InvalidOperationException ("null is invalid as anyType in XmlSerializer");
954 return CreateInvalidAnyTypeException (o.GetType ());
957 protected Exception CreateInvalidAnyTypeException (Type type)
959 return new InvalidOperationException (String.Format ("An object of type '{0}' is invalid as anyType in XmlSerializer", type));
962 protected Exception CreateInvalidEnumValueException (object value, string typeName)
964 return new InvalidOperationException (string.Format(CultureInfo.CurrentCulture,
965 "'{0}' is not a valid value for {1}.", value, typeName));
968 protected static string FromEnum (long value, string[] values, long[] ids, string typeName)
970 return XmlCustomFormatter.FromEnum (value, values, ids, typeName);
974 protected string FromXmlQualifiedName (XmlQualifiedName xmlQualifiedName, bool ignoreEmpty)
976 throw new NotImplementedException ();
980 protected static Assembly ResolveDynamicAssembly (string assemblyFullName)
982 throw new NotImplementedException ();
986 protected bool EscapeName
988 get { throw new NotImplementedException(); }
989 set { throw new NotImplementedException(); }
995 class WriteCallbackInfo
998 public string TypeName;
999 public string TypeNs;
1000 public XmlSerializationWriteCallback Callback;