using System;
using System.Collections;
using System.Xml;
+using System.Xml.Schema;
namespace System.Xml.Serialization {
public abstract class XmlSerializationWriter {
[MonoTODO]
protected XmlSerializationWriter ()
{
- throw new NotImplementedException ();
}
#endregion // Constructors
[MonoTODO ("Implement")]
protected static string FromXmlName (string name)
{
- throw new NotImplementedException ();
+ return XmlCustomFormatter.FromXmlName (name);
}
[MonoTODO ("Implement")]
protected static string FromXmlNCName (string ncName)
{
- throw new NotImplementedException ();
+ return XmlCustomFormatter.FromXmlNCName (ncName);
}
[MonoTODO ("Implement")]
protected static string FromXmlNmToken (string nmToken)
{
- throw new NotImplementedException ();
+ return XmlCustomFormatter.FromXmlNmToken (nmToken);
}
[MonoTODO ("Implement")]
protected static string FromXmlNmTokens (string nmTokens)
{
- throw new NotImplementedException ();
+ return XmlCustomFormatter.FromXmlNmTokens (nmTokens);
}
[MonoTODO ("Implement")]
protected string FromXmlQualifiedName (XmlQualifiedName xmlQualifiedName)
{
- throw new NotImplementedException ();
+ return GetQualifiedName (xmlQualifiedName.Name, xmlQualifiedName.Namespace).ToString ();
+ }
+
+ private XmlQualifiedName GetQualifiedName (string name, string ns)
+ {
+ WriteAttribute ("xmlns", "q1", null, ns);
+ return new XmlQualifiedName (name, "q1");
}
protected abstract void InitCallbacks ();
WriteAttribute (String.Empty, localName, ns, value);
}
- [MonoTODO ("Implement")]
protected void WriteAttribute (string prefix, string localName, string ns, string value)
{
- throw new NotImplementedException ();
+ Writer.WriteAttributeString (prefix, localName, ns, value);
}
[MonoTODO ("Implement")]
[MonoTODO ("Implement")]
protected void WriteElementLiteral (XmlNode node, string name, string ns, bool isNullable, bool any)
{
- throw new NotImplementedException ();
+ WriteStartElement (name, ns);
+ node.WriteTo (Writer);
+ WriteEndElement ();
}
- [MonoTODO ("Implement")]
protected void WriteElementQualifiedName (string localName, XmlQualifiedName value)
{
- throw new NotImplementedException ();
+ WriteElementQualifiedName (localName, String.Empty, value, null);
}
- [MonoTODO ("Implement")]
protected void WriteElementQualifiedName (string localName, string ns, XmlQualifiedName value)
{
- throw new NotImplementedException ();
+ WriteElementQualifiedName (localName, ns, value, null);
}
- [MonoTODO ("Implement")]
protected void WriteElementQualifiedName (string localName, XmlQualifiedName value, XmlQualifiedName xsiType)
{
- throw new NotImplementedException ();
+ WriteElementQualifiedName (localName, String.Empty, value, xsiType);
}
- [MonoTODO ("Implement")]
protected void WriteElementQualifiedName (string localName, string ns, XmlQualifiedName value, XmlQualifiedName xsiType)
{
- throw new NotImplementedException ();
+ WriteStartElement (localName, ns);
+ Writer.WriteString (FromXmlQualifiedName (value));
+ WriteEndElement ();
}
protected void WriteElementString (string localName, string value)
[MonoTODO ("Implement")]
protected void WriteElementString (string localName, string ns, string value, XmlQualifiedName xsiType)
{
- throw new NotImplementedException ();
+ WriteStartElement (localName, ns);
+
+ if (xsiType != null)
+ WriteXsiType (xsiType.Name, xsiType.Namespace);
+
+ Writer.WriteString (value);
+ WriteEndElement ();
}
protected void WriteElementStringRaw (string localName, byte[] value)
[MonoTODO ("Implement")]
protected void WriteElementStringRaw (string localName, string ns, string value, XmlQualifiedName xsiType)
{
- throw new NotImplementedException ();
+ WriteStartElement (localName, ns);
+
+ if (xsiType != null)
+ WriteXsiType (xsiType.Name, xsiType.Namespace);
+
+ Writer.WriteRaw (value);
+ WriteEndElement ();
}
protected void WriteEmptyTag (string name)
WriteEmptyTag (name, String.Empty);
}
- [MonoTODO ("Implement")]
+ [MonoTODO ("Verify")]
protected void WriteEmptyTag (string name, string ns)
{
- throw new NotImplementedException ();
+ Writer.WriteStartElement (name, ns);
+ Writer.WriteEndElement ();
}
protected void WriteEndElement ()
[MonoTODO ("Implement")]
protected void WriteEndElement (object o)
{
- throw new NotImplementedException ();
+ Writer.WriteEndElement ();
}
[MonoTODO ("Implement")]
WriteStartElement (name, ns, o, false);
}
- [MonoTODO ("Implement")]
+ [MonoTODO]
protected void WriteStartElement (string name, string ns, object o, bool writePrefixed)
{
- throw new NotImplementedException ();
+ if (writePrefixed)
+ Writer.WriteStartElement (String.Empty, name, ns);
+ else
+ Writer.WriteStartElement (name, ns);
}
- [MonoTODO ("Implement")]
+ [MonoTODO ("Include XMLSchema-Instance namespace")]
protected void WriteTypedPrimitive (string name, string ns, object o, bool xsiType)
{
- throw new NotImplementedException ();
+ if (!xsiType) {
+ WriteElementString (name, ns, o.ToString ());
+ return;
+ }
+
+ XmlQualifiedName xsiTypeQName = new XmlQualifiedName (o.GetType ().Name, XmlSchema.Namespace);
+ WriteElementString (name, ns, o.ToString (), xsiTypeQName);
}
protected void WriteValue (byte[] value)
throw new NotImplementedException ();
}
- [MonoTODO ("Implement")]
+ [MonoTODO ("Change prefix")]
protected void WriteXsiType (string name, string ns)
{
- throw new NotImplementedException ();
+ WriteAttribute ("d0p1", "type", null, GetQualifiedName (name, ns).ToString ());
}
+
#endregion