ixmlserializable

Implementing IXmlSerializable on a generated class that has XmlTypeAttribute

Basically, the initial problem is I need to make a boolean value serialize as 0 or 1. The solution I found was to implement IXmlSerializable, which I did. Unfortunately the class I'm trying to serialize is generated code off a schema and has an XmlTypeAttribute on it. When I try to (de)serialize the object with the XmlSerializer created ...

Issue allowing custom Xml Serialization/Deserialization on certain types of field

I've been working with Xml Serialization/Deserialization in .net and wanted a method where the serialization/deserialization process would only be applied to certain parts of an Xml fragment. This is so I can keep certain parts of the fragment in Xml after the deserialization process. To do this I thought it would be best to create a ne...

Cast errors with IXmlSerializable

I am trying to use the IXmlSerializable interface to deserialize an Object (I am using it because I need specific control over what gets deserialized and what does not. See my previous question for more information). However, I'm stumped as to the error message I get. Below is the error message I get (I have changed some names for clarit...

Different return XML in a WCF Operation

I am writing a service to a international HTTP standard, and there is one method that can return three different XML results, call them Single, Multiple and Error. Now I've written an IXmlSerializable class that can consume each of these results and generate them. However, WCF seems to insist that I can only have a single return XML root...

representing an XML config file with an IXmlSerializable class

I'm writing in C# and trying to represent an XML config file through an IXmlSerializable class. I'm unsure how to represent the nested elements in my config file, though, such as logLevel: <?xml version="1.0" encoding="utf-8" ?> <configuration> <logging> <logLevel>Error</logLevel> </logging> <credentials> <user>user123</u...

Cannot WriteXML for DataTable because Windows Search Returns String Array for Authors Property

The System.Author Windows property is a multiple value string. Windows Search returns this value as an array of strings in a DataColumn. (The column's data-type is string[] or String().) When I call the WriteXML method on the resulting data-table, I get the following InvalidOperationException exception. Is there a way to specify the da...

Using IXmlSerializable interface on complex object graph

If using custom XML Serialization (IXmlSerialiable), on a complex object that contains properties with constituent complex objects which do NOT use custom IXmlSerializable interface, how do you specify, in the IXmlSerializable.ReadXml(XmlReader reader) method, that you want the deserializer to use the ordinary deserialization on those ch...

IXmlSerializable dictionary in C# without 'Key'/'Value' nodes

I'm trying to serialize a dictionary in C#. All the examples I've been able to find create XML like the following: <Dictionary> <ArrayOfEntries> <Entry> <Key>myFirstKey</Key> <Value>myFirstValue</Value> </Entry> <Entry> <Key>mySecondKey</Key> <Value>mySecondVal...

Serialization: Change the name of the root node without changing the class name

Goal Take a class named "Item" and output its serialized XML as: <Template><!--some properties --></Template> Problem The root node is derived off the class name that is implementing IXmlSerializable. // By the time I get here 'writer' already has a root node public void WriteXml(XmlWriter writer) { writer.Wri...

IXMLSerializeable

I need to implement IXMLSerializeable for custom serialization on 2 members, but I want the rest of the members to be serialized with the default serialization. Or at least, is there a way for me to invoke the standard serialization on the other members? The types of the other members are very large and deeply neseted classes, and it wou...

How does IXmlSerializable let me avoid base64's size inflation?

From MSDN: There are two reasons to implement this interface. The first is to control how your object is serialized or deserialized by the XmlSerializer. For example, you can chunk data into bytes instead of buffering large data sets, and also avoid the inflation that occurs when the data is encoded using Base64 encoding. How does ...

"ReadElementContentAsBase64 method is not supported on this XmlReader"

using System.IO; using System.Runtime.Serialization; using System.Xml; using System.Xml.Schema; using System.Xml.Serialization; namespace XmlTest { class TestClass : IXmlSerializable { public XmlSchema GetSchema() { return null; } public void ReadXml(XmlReader reader) { ...

Can traffic be streamed from client to Web Service using IXmlSerializable in C#?

Using the following as a guide I am attempting to implement a streaming file upload from a client to a server through a Web Service. The example provided below is streaming in the opposite direction from Web Service on a server to client. I am using IIS 7 on Windows 2008 R2 and .Net Framework 3.5 How To: Chunk Serialized Data http://m...