Inheritance: System.Xml.XmlWriter
Exemplo n.º 1
0
        static void WriteIXmlSerializable(XmlWriterDelegator xmlWriter, object obj, XmlSerializableWriter xmlSerializableWriter)
        {
            xmlSerializableWriter.BeginWrite(xmlWriter.Writer, obj);
            IXmlSerializable xmlSerializable = obj as IXmlSerializable;

            if (xmlSerializable != null)
            {
                xmlSerializable.WriteXml(xmlSerializableWriter);
            }
            else
            {
                XmlElement xmlElement = obj as XmlElement;
                if (xmlElement != null)
                {
                    xmlElement.WriteTo(xmlSerializableWriter);
                }
                else
                {
                    XmlNode[] xmlNodes = obj as XmlNode[];
                    if (xmlNodes != null)
                    {
                        foreach (XmlNode xmlNode in xmlNodes)
                        {
                            xmlNode.WriteTo(xmlSerializableWriter);
                        }
                    }
                    else
                    {
                        throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(XmlObjectSerializer.CreateSerializationException(SR.GetString(SR.UnknownXmlType, DataContract.GetClrTypeFullName(obj.GetType()))));
                    }
                }
            }
            xmlSerializableWriter.EndWrite();
        }
 internal void WriteIXmlSerializable(XmlWriterDelegator xmlWriter, object obj)
 {
     if (_xmlSerializableWriter == null)
     {
         _xmlSerializableWriter = new XmlSerializableWriter();
     }
     WriteIXmlSerializable(xmlWriter, obj, _xmlSerializableWriter);
 }
Exemplo n.º 3
0
        private static void WriteIXmlSerializable(XmlWriterDelegator xmlWriter, object obj, XmlSerializableWriter xmlSerializableWriter)
        {
            xmlSerializableWriter.BeginWrite(xmlWriter.Writer, obj);
            IXmlSerializable xmlSerializable = obj as IXmlSerializable;

            if (xmlSerializable != null)
            {
                xmlSerializable.WriteXml(xmlSerializableWriter);
            }
            xmlSerializableWriter.EndWrite();
        }
        private static void WriteIXmlSerializable(XmlWriterDelegator xmlWriter, object obj, XmlSerializableWriter xmlSerializableWriter)
        {
            xmlSerializableWriter.BeginWrite(xmlWriter.Writer, obj);
            IXmlSerializable serializable = obj as IXmlSerializable;

            if (serializable != null)
            {
                serializable.WriteXml(xmlSerializableWriter);
            }
            else
            {
                XmlElement element = obj as XmlElement;
                if (element != null)
                {
                    element.WriteTo(xmlSerializableWriter);
                }
                else
                {
                    System.Xml.XmlNode[] nodeArray = obj as System.Xml.XmlNode[];
                    if (nodeArray == null)
                    {
                        throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(XmlObjectSerializer.CreateSerializationException(System.Runtime.Serialization.SR.GetString("UnknownXmlType", new object[] { DataContract.GetClrTypeFullName(obj.GetType()) })));
                    }
                    foreach (System.Xml.XmlNode node in nodeArray)
                    {
                        node.WriteTo(xmlSerializableWriter);
                    }
                }
            }
            xmlSerializableWriter.EndWrite();
        }