int max_items = 0x10000; // FIXME: could be from config.
+ bool names_filled;
XmlDictionaryString root_name, root_ns;
public DataContractSerializer (Type type)
XmlDictionary d = new XmlDictionary ();
root_name = d.Add (name);
root_ns = d.Add (ns);
+ names_filled = true;
}
void Initialize (
get { return preserve_refs; }
}
- [MonoTODO]
public override bool IsStartObject (XmlDictionaryReader reader)
{
- throw new NotImplementedException ();
+ if (reader == null)
+ throw new ArgumentNullException ("reader");
+ reader.MoveToContent ();
+ return reader.IsStartElement (root_name, root_ns);
}
// SP1
return ReadObject (XmlDictionaryReader.CreateDictionaryReader (reader));
}
+ public override object ReadObject (XmlReader reader, bool verifyObjectName)
+ {
+ return ReadObject (XmlDictionaryReader.CreateDictionaryReader (reader), verifyObjectName);
+ }
+
[MonoTODO]
public override object ReadObject (XmlDictionaryReader reader, bool verifyObjectName)
{
known_types.RemoveAt (startTypeCount);
}
+ public override void WriteObjectContent (XmlWriter writer, object graph)
+ {
+ XmlDictionaryWriter w = XmlDictionaryWriter.CreateDictionaryWriter (writer);
+ WriteObjectContent (w, graph);
+ }
+
// SP1
public override void WriteStartObject (
XmlWriter writer, object graph)
if (graph == null) {
- writer.WriteStartElement (root_name.Value, root_ns.Value);
+ if (names_filled)
+ writer.WriteStartElement (root_name.Value, root_ns.Value);
+ else
+ writer.WriteStartElement (root_name, root_ns);
writer.WriteAttributeString ("i", "nil", XmlSchema.InstanceNamespace, "true");
return;
}
known_types.Add (graph.GetType ());
- writer.WriteStartElement (root_name.Value, root_ns.Value);
+ if (names_filled)
+ writer.WriteStartElement (root_name.Value, root_ns.Value);
+ else
+ writer.WriteStartElement (root_name, root_ns);
if (root_ns.Value != root_qname.Namespace)
if (root_qname.Namespace != KnownTypeCollection.MSSimpleNamespace)
writer.WriteXmlnsAttribute (null, root_qname.Namespace);