static private WriteNull ( System.Runtime.Serialization.XmlWriterDelegator writer ) : void | ||
writer | System.Runtime.Serialization.XmlWriterDelegator | |
return | void |
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); } }
internal void InternalWriteObjectContent(XmlWriterDelegator writer, object graph, System.Runtime.Serialization.DataContractResolver dataContractResolver) { if (this.MaxItemsInObjectGraph == 0) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(XmlObjectSerializer.CreateSerializationException(System.Runtime.Serialization.SR.GetString("ExceededMaxItemsQuota", new object[] { this.MaxItemsInObjectGraph }))); } DataContract rootContract = this.RootContract; Type underlyingType = rootContract.UnderlyingType; Type objType = (graph == null) ? underlyingType : graph.GetType(); if (this.dataContractSurrogate != null) { graph = SurrogateToDataContractType(this.dataContractSurrogate, graph, underlyingType, ref objType); } if (dataContractResolver == null) { dataContractResolver = this.DataContractResolver; } if (graph == null) { if (base.IsRootXmlAny(this.rootName, rootContract)) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(XmlObjectSerializer.CreateSerializationException(System.Runtime.Serialization.SR.GetString("IsAnyCannotBeNull", new object[] { underlyingType }))); } XmlObjectSerializer.WriteNull(writer); } else if (underlyingType == objType) { if (rootContract.CanContainReferences) { XmlObjectSerializerWriteContext context = XmlObjectSerializerWriteContext.CreateContext(this, rootContract, dataContractResolver); context.HandleGraphAtTopLevel(writer, graph, rootContract); context.SerializeWithoutXsiType(rootContract, writer, graph, underlyingType.TypeHandle); } else { rootContract.WriteXmlValue(writer, graph, null); } } else { XmlObjectSerializerWriteContext context2 = null; if (base.IsRootXmlAny(this.rootName, rootContract)) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(XmlObjectSerializer.CreateSerializationException(System.Runtime.Serialization.SR.GetString("IsAnyCannotBeSerializedAsDerivedType", new object[] { objType, rootContract.UnderlyingType }))); } rootContract = GetDataContract(rootContract, underlyingType, objType); context2 = XmlObjectSerializerWriteContext.CreateContext(this, this.RootContract, dataContractResolver); if (rootContract.CanContainReferences) { context2.HandleGraphAtTopLevel(writer, graph, rootContract); } context2.OnHandleIsReference(writer, rootContract, graph); context2.SerializeWithXsiTypeAtTopLevel(rootContract, writer, graph, underlyingType.TypeHandle, objType); } }
protected virtual void WriteNull(XmlWriterDelegator xmlWriter) { XmlObjectSerializer.WriteNull(xmlWriter); }