private void InternalWriteObjectContent(XmlWriterDelegator writer, object graph, DataContract contract, Hashtable surrogateDataContracts)
{
if (this.MaxItemsInObjectGraph == 0)
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(XmlObjectSerializer.CreateSerializationException(System.Runtime.Serialization.SR.GetString("ExceededMaxItemsQuota", new object[] { this.MaxItemsInObjectGraph })));
}
if (base.IsRootXmlAny(this.rootName, contract))
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(XmlObjectSerializer.CreateSerializationException(System.Runtime.Serialization.SR.GetString("IsAnyNotSupportedByNetDataContractSerializer", new object[] { contract.UnderlyingType })));
}
if (graph == null)
{
XmlObjectSerializer.WriteNull(writer);
}
else
{
Type type = graph.GetType();
if (contract.UnderlyingType != type)
{
contract = this.GetDataContract(graph, ref surrogateDataContracts);
}
XmlObjectSerializerWriteContext context = null;
if (contract.CanContainReferences)
{
context = XmlObjectSerializerWriteContext.CreateContext(this, surrogateDataContracts);
context.HandleGraphAtTopLevel(writer, graph, contract);
}
WriteClrTypeInfo(writer, contract, this.binder);
contract.WriteXmlValue(writer, graph, context);
}
}