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
45 : XmlSerializationGeneratedCode
50 ObjectIDGenerator idGenerator;
52 bool topLevelElement = false;
56 Queue referencedElements;
58 Hashtable serializedObjects;
59 const string xmlNamespace = "http://www.w3.org/2000/xmlns/";
60 const string unexpectedTypeError = "The type {0} was not expected. Use the" +
61 " XmlInclude or SoapInclude attribute to specify types that are not known statically.";
67 protected XmlSerializationWriter ()
70 serializedObjects = new Hashtable ();
73 internal void Initialize (XmlWriter writer, XmlSerializerNamespaces nss)
78 namespaces = new ArrayList ();
79 foreach (XmlQualifiedName ns in nss.ToArray())
80 if (ns.Name != "" && ns.Namespace != "")
85 #endregion // Constructors
89 protected ArrayList Namespaces {
90 get { return namespaces; }
91 set { namespaces = value; }
94 protected XmlWriter Writer {
95 get { return writer; }
96 set { writer = value; }
99 #endregion // Properties
103 protected void AddWriteCallback (Type type, string typeName, string typeNs, XmlSerializationWriteCallback callback)
105 WriteCallbackInfo info = new WriteCallbackInfo ();
107 info.TypeName = typeName;
108 info.TypeNs = typeNs;
109 info.Callback = callback;
111 if (callbacks == null) callbacks = new Hashtable ();
112 callbacks.Add (type, info);
115 protected Exception CreateChoiceIdentifierValueException (string value, string identifier, string name, string ns)
117 string message = string.Format ("Value '{0}' of the choice"
118 + " identifier '{1}' does not match element '{2}'"
119 + " from namespace '{3}'.", value, identifier,
121 return new InvalidOperationException (message);
124 protected Exception CreateInvalidChoiceIdentifierValueException (string type, string identifier)
126 string message = string.Format ("Invalid or missing choice"
127 + " identifier '{0}' of type '{1}'.", identifier,
129 return new InvalidOperationException (message);
132 protected Exception CreateMismatchChoiceException (string value, string elementName, string enumValue)
134 string message = String.Format ("Value of {0} mismatches the type of {1}, you need to set it to {2}.", elementName, value, enumValue);
135 return new InvalidOperationException (message);
138 protected Exception CreateUnknownAnyElementException (string name, string ns)
140 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);
141 return new InvalidOperationException (message);
144 protected Exception CreateUnknownTypeException (object o)
146 return CreateUnknownTypeException (o.GetType ());
149 protected Exception CreateUnknownTypeException (Type type)
151 string message = String.Format ("The type {0} may not be used in this context.", type);
152 return new InvalidOperationException (message);
155 protected static byte[] FromByteArrayBase64 (byte[] value)
160 protected static string FromByteArrayHex (byte[] value)
162 return XmlCustomFormatter.FromByteArrayHex (value);
165 protected static string FromChar (char value)
167 return XmlCustomFormatter.FromChar (value);
170 protected static string FromDate (DateTime value)
172 return XmlCustomFormatter.FromDate (value);
175 protected static string FromDateTime (DateTime value)
177 return XmlCustomFormatter.FromDateTime (value);
180 protected static string FromEnum (long value, string[] values, long[] ids)
182 return XmlCustomFormatter.FromEnum (value, values, ids);
185 protected static string FromTime (DateTime value)
187 return XmlCustomFormatter.FromTime (value);
190 protected static string FromXmlName (string name)
192 return XmlCustomFormatter.FromXmlName (name);
195 protected static string FromXmlNCName (string ncName)
197 return XmlCustomFormatter.FromXmlNCName (ncName);
200 protected static string FromXmlNmToken (string nmToken)
202 return XmlCustomFormatter.FromXmlNmToken (nmToken);
205 protected static string FromXmlNmTokens (string nmTokens)
207 return XmlCustomFormatter.FromXmlNmTokens (nmTokens);
210 protected string FromXmlQualifiedName (XmlQualifiedName xmlQualifiedName)
212 if (xmlQualifiedName == null || xmlQualifiedName == XmlQualifiedName.Empty)
215 return GetQualifiedName (xmlQualifiedName.Name, xmlQualifiedName.Namespace);
218 private string GetId (object o, bool addToReferencesList)
220 if (idGenerator == null) idGenerator = new ObjectIDGenerator ();
223 long lid = idGenerator.GetId (o, out firstTime);
224 return String.Format (CultureInfo.InvariantCulture, "id{0}", lid);
228 bool AlreadyQueued (object ob)
230 if (idGenerator == null) return false;
233 idGenerator.HasId (ob, out firstTime);
237 private string GetNamespacePrefix (string ns)
239 string prefix = Writer.LookupPrefix (ns);
242 prefix = String.Format (CultureInfo.InvariantCulture, "q{0}", ++qnameCount);
243 WriteAttribute ("xmlns", prefix, null, ns);
248 private string GetQualifiedName (string name, string ns)
250 if (ns == String.Empty) return name;
252 string prefix = GetNamespacePrefix (ns);
253 if (prefix == String.Empty)
256 return String.Format ("{0}:{1}", prefix, name);
259 protected abstract void InitCallbacks ();
261 protected void TopLevelElement ()
263 topLevelElement = true;
266 protected void WriteAttribute (string localName, byte[] value)
268 WriteAttribute (localName, String.Empty, value);
271 protected void WriteAttribute (string localName, string value)
273 WriteAttribute (String.Empty, localName, String.Empty, value);
276 protected void WriteAttribute (string localName, string ns, byte[] value)
281 Writer.WriteStartAttribute (localName, ns);
283 Writer.WriteEndAttribute ();
286 protected void WriteAttribute (string localName, string ns, string value)
288 WriteAttribute (null, localName, ns, value);
291 protected void WriteAttribute (string prefix, string localName, string ns, string value)
296 Writer.WriteAttributeString (prefix, localName, ns, value);
299 void WriteXmlNode (XmlNode node)
301 if (node is XmlDocument)
302 node = ((XmlDocument) node).DocumentElement;
304 node.WriteTo (Writer);
307 protected void WriteElementEncoded (XmlNode node, string name, string ns, bool isNullable, bool any)
309 if (name != string.Empty)
314 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);
342 Writer.WriteStartElement (name, ns);
344 Writer.WriteEndElement ();
351 protected void WriteElementQualifiedName (string localName, XmlQualifiedName value)
353 WriteElementQualifiedName (localName, String.Empty, value, null);
356 protected void WriteElementQualifiedName (string localName, string ns, XmlQualifiedName value)
358 WriteElementQualifiedName (localName, ns, value, null);
361 protected void WriteElementQualifiedName (string localName, XmlQualifiedName value, XmlQualifiedName xsiType)
363 WriteElementQualifiedName (localName, String.Empty, value, xsiType);
366 protected void WriteElementQualifiedName (string localName, string ns, XmlQualifiedName value, XmlQualifiedName xsiType)
368 localName = XmlCustomFormatter.FromXmlNCName (localName);
369 WriteStartElement (localName, ns);
370 if (xsiType != null) WriteXsiType (xsiType.Name, xsiType.Namespace);
371 Writer.WriteString (FromXmlQualifiedName (value));
375 protected void WriteElementString (string localName, string value)
377 WriteElementString (localName, String.Empty, value, null);
380 protected void WriteElementString (string localName, string ns, string value)
382 WriteElementString (localName, ns, value, null);
385 protected void WriteElementString (string localName, string value, XmlQualifiedName xsiType)
387 WriteElementString (localName, String.Empty, value, xsiType);
390 protected void WriteElementString (string localName, string ns, string value, XmlQualifiedName xsiType)
392 if (value == null) return;
394 if (xsiType != null) {
395 localName = XmlCustomFormatter.FromXmlNCName (localName);
396 WriteStartElement (localName, ns);
397 WriteXsiType (xsiType.Name, xsiType.Namespace);
398 Writer.WriteString (value);
402 Writer.WriteElementString (localName, ns, value);
405 protected void WriteElementStringRaw (string localName, byte[] value)
407 WriteElementStringRaw (localName, String.Empty, value, null);
410 protected void WriteElementStringRaw (string localName, string value)
412 WriteElementStringRaw (localName, String.Empty, value, null);
415 protected void WriteElementStringRaw (string localName, byte[] value, XmlQualifiedName xsiType)
417 WriteElementStringRaw (localName, String.Empty, value, xsiType);
420 protected void WriteElementStringRaw (string localName, string ns, byte[] value)
422 WriteElementStringRaw (localName, ns, value, null);
425 protected void WriteElementStringRaw (string localName, string ns, string value)
427 WriteElementStringRaw (localName, ns, value, null);
430 protected void WriteElementStringRaw (string localName, string value, XmlQualifiedName xsiType)
432 WriteElementStringRaw (localName, String.Empty, value, null);
435 protected void WriteElementStringRaw (string localName, string ns, byte[] value, XmlQualifiedName xsiType)
440 WriteStartElement (localName, ns);
443 WriteXsiType (xsiType.Name, xsiType.Namespace);
445 if (value.Length > 0)
446 Writer.WriteBase64(value,0,value.Length);
450 protected void WriteElementStringRaw (string localName, string ns, string value, XmlQualifiedName xsiType)
452 localName = XmlCustomFormatter.FromXmlNCName (localName);
453 WriteStartElement (localName, ns);
456 WriteXsiType (xsiType.Name, xsiType.Namespace);
458 Writer.WriteRaw (value);
462 protected void WriteEmptyTag (string name)
464 WriteEmptyTag (name, String.Empty);
467 protected void WriteEmptyTag (string name, string ns)
469 name = XmlCustomFormatter.FromXmlName (name);
470 WriteStartElement (name, ns);
474 protected void WriteEndElement ()
476 WriteEndElement (null);
479 protected void WriteEndElement (object o)
482 serializedObjects.Remove (o);
484 Writer.WriteEndElement ();
487 protected void WriteId (object o)
489 WriteAttribute ("id", GetId (o, true));
492 protected void WriteNamespaceDeclarations (XmlSerializerNamespaces xmlns)
496 foreach (DictionaryEntry qn in xmlns.Namespaces) {
497 if ((string) qn.Value != String.Empty && Writer.LookupPrefix ((string) qn.Value) != (string) qn.Key)
498 WriteAttribute ("xmlns", (string) qn.Key, xmlNamespace, (string) qn.Value);
502 protected void WriteNullableQualifiedNameEncoded (string name, string ns, XmlQualifiedName value, XmlQualifiedName xsiType)
505 WriteElementQualifiedName (name, ns, value, xsiType);
507 WriteNullTagEncoded (name, ns);
510 protected void WriteNullableQualifiedNameLiteral (string name, string ns, XmlQualifiedName value)
513 WriteElementQualifiedName (name, ns, value);
515 WriteNullTagLiteral (name, ns);
518 protected void WriteNullableStringEncoded (string name, string ns, string value, XmlQualifiedName xsiType)
521 WriteElementString (name, ns, value, xsiType);
523 WriteNullTagEncoded (name, ns);
526 protected void WriteNullableStringEncodedRaw (string name, string ns, byte[] value, XmlQualifiedName xsiType)
529 WriteNullTagEncoded (name, ns);
531 WriteElementStringRaw (name, ns, value, xsiType);
534 protected void WriteNullableStringEncodedRaw (string name, string ns, string value, XmlQualifiedName xsiType)
537 WriteNullTagEncoded (name, ns);
539 WriteElementStringRaw (name, ns, value, xsiType);
542 protected void WriteNullableStringLiteral (string name, string ns, string value)
545 WriteElementString (name, ns, value, null);
547 WriteNullTagLiteral (name, ns);
550 protected void WriteNullableStringLiteralRaw (string name, string ns, byte[] value)
553 WriteNullTagLiteral (name, ns);
555 WriteElementStringRaw (name, ns, value);
558 protected void WriteNullableStringLiteralRaw (string name, string ns, string value)
561 WriteNullTagLiteral (name, ns);
563 WriteElementStringRaw (name, ns, value);
566 protected void WriteNullTagEncoded (string name)
568 WriteNullTagEncoded (name, String.Empty);
571 protected void WriteNullTagEncoded (string name, string ns)
573 Writer.WriteStartElement (name, ns);
574 Writer.WriteAttributeString ("nil", XmlSchema.InstanceNamespace, "true");
575 Writer.WriteEndElement ();
578 protected void WriteNullTagLiteral (string name)
580 WriteNullTagLiteral (name, String.Empty);
583 protected void WriteNullTagLiteral (string name, string ns)
585 WriteStartElement (name, ns);
586 Writer.WriteAttributeString ("nil", XmlSchema.InstanceNamespace, "true");
590 protected void WritePotentiallyReferencingElement (string n, string ns, object o)
592 WritePotentiallyReferencingElement (n, ns, o, null, false, false);
595 protected void WritePotentiallyReferencingElement (string n, string ns, object o, Type ambientType)
597 WritePotentiallyReferencingElement (n, ns, o, ambientType, false, false);
600 protected void WritePotentiallyReferencingElement (string n, string ns, object o, Type ambientType, bool suppressReference)
602 WritePotentiallyReferencingElement (n, ns, o, ambientType, suppressReference, false);
605 protected void WritePotentiallyReferencingElement (string n, string ns, object o, Type ambientType, bool suppressReference, bool isNullable)
609 if (isNullable) WriteNullTagEncoded (n, ns);
613 var t = o.GetType ();
615 WriteStartElement (n, ns, true);
617 CheckReferenceQueue ();
619 if (callbacks != null && callbacks.ContainsKey (o.GetType ()))
621 WriteCallbackInfo info = (WriteCallbackInfo) callbacks[t];
625 else if (suppressReference) {
626 Writer.WriteAttributeString ("id", GetId (o, false));
627 if (ambientType != t) WriteXsiType(info.TypeName, info.TypeNs);
631 if (!AlreadyQueued (o)) referencedElements.Enqueue (o);
632 Writer.WriteAttributeString ("href", "#" + GetId (o, true));
637 // Must be a primitive type or array of primitives
638 TypeData td = TypeTranslator.GetTypeData (t, null, true);
639 if (td.SchemaType == SchemaTypes.Primitive) {
640 if (t != ambientType)
641 WriteXsiType (td.XmlType, XmlSchema.Namespace);
642 Writer.WriteString (XmlCustomFormatter.ToXmlString (td, o));
643 } else if (IsPrimitiveArray (td)) {
644 if (!AlreadyQueued (o)) referencedElements.Enqueue (o);
645 Writer.WriteAttributeString ("href", "#" + GetId (o, true));
647 throw new InvalidOperationException ("Invalid type: " + t.FullName);
654 protected void WriteReferencedElements ()
656 if (referencedElements == null) return;
657 if (callbacks == null) return;
659 while (referencedElements.Count > 0)
661 object o = referencedElements.Dequeue ();
662 TypeData td = TypeTranslator.GetTypeData (o.GetType ());
663 WriteCallbackInfo info = (WriteCallbackInfo) callbacks[o.GetType()];
666 WriteStartElement (info.TypeName, info.TypeNs, true);
667 Writer.WriteAttributeString ("id", GetId (o, false));
669 if (td.SchemaType != SchemaTypes.Array) // Array use its own "arrayType" attribute
670 WriteXsiType(info.TypeName, info.TypeNs);
674 } else if (IsPrimitiveArray (td)) {
680 bool IsPrimitiveArray (TypeData td)
682 if (td.SchemaType == SchemaTypes.Array) {
683 if (td.ListItemTypeData.SchemaType == SchemaTypes.Primitive || td.ListItemType == typeof(object))
685 return IsPrimitiveArray (td.ListItemTypeData);
690 void WriteArray (object o, TypeData td)
692 TypeData itemTypeData = td;
697 itemTypeData = itemTypeData.ListItemTypeData;
698 xmlType = itemTypeData.XmlType;
701 while (itemTypeData.SchemaType == SchemaTypes.Array );
706 WriteStartElement("Array", XmlSerializer.EncodingNamespace, true);
707 Writer.WriteAttributeString("id", GetId(o, false));
708 if (td.SchemaType == SchemaTypes.Array) {
711 Writer.WriteAttributeString("arrayType", XmlSerializer.EncodingNamespace, GetQualifiedName(xmlType, XmlSchema.Namespace) + "[" + len.ToString() + "]");
712 for (int i = 0; i < len; i++) {
713 WritePotentiallyReferencingElement("Item", "", a.GetValue(i), td.ListItemType, false, true);
720 protected void WriteReferencingElement (string n, string ns, object o)
722 WriteReferencingElement (n, ns, o, false);
725 protected void WriteReferencingElement (string n, string ns, object o, bool isNullable)
729 if (isNullable) WriteNullTagEncoded (n, ns);
734 CheckReferenceQueue ();
735 if (!AlreadyQueued (o)) referencedElements.Enqueue (o);
737 Writer.WriteStartElement (n, ns);
738 Writer.WriteAttributeString ("href", "#" + GetId (o, true));
739 Writer.WriteEndElement ();
743 void CheckReferenceQueue ()
745 if (referencedElements == null)
747 referencedElements = new Queue ();
753 protected void WriteRpcResult (string name, string ns)
755 throw new NotImplementedException ();
758 protected void WriteSerializable (IXmlSerializable serializable, string name, string ns, bool isNullable)
760 WriteSerializable (serializable, name, ns, isNullable, true);
764 void WriteSerializable (IXmlSerializable serializable, string name, string ns, bool isNullable, bool wrapped)
766 if (serializable == null)
768 if (isNullable && wrapped) WriteNullTagLiteral (name, ns);
774 Writer.WriteStartElement (name, ns);
775 serializable.WriteXml (Writer);
777 Writer.WriteEndElement ();
781 protected void WriteStartDocument ()
783 if (Writer.WriteState == WriteState.Start)
784 Writer.WriteStartDocument ();
787 protected void WriteStartElement (string name)
789 WriteStartElement (name, String.Empty, null, false);
792 protected void WriteStartElement (string name, string ns)
794 WriteStartElement (name, ns, null, false);
797 protected void WriteStartElement (string name, string ns, bool writePrefixed)
799 WriteStartElement (name, ns, null, writePrefixed);
802 protected void WriteStartElement (string name, string ns, object o)
804 WriteStartElement (name, ns, o, false);
807 protected void WriteStartElement (string name, string ns, object o, bool writePrefixed)
809 WriteStartElement (name, ns, o, writePrefixed, namespaces);
812 protected void WriteStartElement (string name, string ns, Object o, bool writePrefixed, XmlSerializerNamespaces xmlns)
814 WriteStartElement (name, ns, o, writePrefixed, xmlns != null ? xmlns.ToArray () : null);
817 void WriteStartElement (string name, string ns, object o, bool writePrefixed, ICollection namespaces)
821 if (serializedObjects.Contains (o))
822 throw new InvalidOperationException ("A circular reference was detected while serializing an object of type " + o.GetType().Name);
824 serializedObjects [o] = o;
827 string prefix = null;
829 if (topLevelElement && ns != null && ns.Length != 0)
831 if (namespaces != null)
832 foreach (XmlQualifiedName qn in namespaces)
833 if (qn.Namespace == ns) {
835 writePrefixed = true;
840 if (writePrefixed && ns != string.Empty)
842 name = XmlCustomFormatter.FromXmlName (name);
845 prefix = Writer.LookupPrefix (ns);
846 if (prefix == null || prefix.Length == 0)
847 prefix = "q" + (++qnameCount);
848 Writer.WriteStartElement (prefix, name, ns);
850 Writer.WriteStartElement (name, ns);
854 if (namespaces != null) {
855 foreach (XmlQualifiedName qn in namespaces)
857 string currentPrefix = Writer.LookupPrefix (qn.Namespace);
858 if (currentPrefix != null && currentPrefix.Length != 0) continue;
860 WriteAttribute ("xmlns",qn.Name,xmlNamespace,qn.Namespace);
863 topLevelElement = false;
867 protected void WriteTypedPrimitive (string name, string ns, object o, bool xsiType)
870 TypeData td = TypeTranslator.GetTypeData (o.GetType (), null, true);
871 if (td.SchemaType != SchemaTypes.Primitive)
872 throw new InvalidOperationException (String.Format ("The type of the argument object '{0}' is not primitive.", td.FullTypeName));
875 ns = td.IsXsdType ? XmlSchema.Namespace : XmlSerializer.WsdlTypesNamespace;
879 name = XmlCustomFormatter.FromXmlName (name);
880 Writer.WriteStartElement (name, ns);
882 if (o is XmlQualifiedName)
883 value = FromXmlQualifiedName ((XmlQualifiedName) o);
885 value = XmlCustomFormatter.ToXmlString (td, o);
889 if (td.SchemaType != SchemaTypes.Primitive)
890 throw new InvalidOperationException (string.Format (unexpectedTypeError, o.GetType().FullName));
891 WriteXsiType (td.XmlType, td.IsXsdType ? XmlSchema.Namespace : XmlSerializer.WsdlTypesNamespace);
896 Writer.WriteEndElement ();
899 protected void WriteValue (byte[] value)
901 Writer.WriteBase64 (value, 0, value.Length);
904 protected void WriteValue (string value)
907 Writer.WriteString (value);
910 protected void WriteXmlAttribute (XmlNode node)
912 WriteXmlAttribute (node, null);
915 protected void WriteXmlAttribute (XmlNode node, object container)
917 XmlAttribute attr = node as XmlAttribute;
919 throw new InvalidOperationException ("The node must be either type XmlAttribute or a derived type.");
921 if (attr.NamespaceURI == XmlSerializer.WsdlNamespace)
923 // The wsdl arrayType attribute needs special handling
924 if (attr.LocalName == "arrayType") {
925 string ns, type, dimensions;
926 TypeTranslator.ParseArrayType (attr.Value, out type, out ns, out dimensions);
927 string value = GetQualifiedName (type + dimensions, ns);
928 WriteAttribute (attr.Prefix, attr.LocalName, attr.NamespaceURI, value);
933 WriteAttribute (attr.Prefix, attr.LocalName, attr.NamespaceURI, attr.Value);
936 protected void WriteXsiType (string name, string ns)
938 if (ns != null && ns != string.Empty)
939 WriteAttribute ("type", XmlSchema.InstanceNamespace, GetQualifiedName (name, ns));
941 WriteAttribute ("type", XmlSchema.InstanceNamespace, name);
945 protected Exception CreateInvalidAnyTypeException (object o)
948 return new InvalidOperationException ("null is invalid as anyType in XmlSerializer");
950 return CreateInvalidAnyTypeException (o.GetType ());
953 protected Exception CreateInvalidAnyTypeException (Type type)
955 return new InvalidOperationException (String.Format ("An object of type '{0}' is invalid as anyType in XmlSerializer", type));
958 protected Exception CreateInvalidEnumValueException (object value, string typeName)
960 return new InvalidOperationException (string.Format(CultureInfo.CurrentCulture,
961 "'{0}' is not a valid value for {1}.", value, typeName));
964 protected static string FromEnum (long value, string[] values, long[] ids, string typeName)
966 return XmlCustomFormatter.FromEnum (value, values, ids, typeName);
970 protected string FromXmlQualifiedName (XmlQualifiedName xmlQualifiedName, bool ignoreEmpty)
972 throw new NotImplementedException ();
976 protected static Assembly ResolveDynamicAssembly (string assemblyFullName)
978 throw new NotImplementedException ();
982 protected bool EscapeName
984 get { throw new NotImplementedException(); }
985 set { throw new NotImplementedException(); }
990 class WriteCallbackInfo
993 public string TypeName;
994 public string TypeNs;
995 public XmlSerializationWriteCallback Callback;