XML : Is it possible to use XmlDictionaryWriter with XDocument?

There is very interesting XmlDictionaryWriter class which can be instantiated by calling a static method CreateBinaryWriter. That method takes a number of parameters and XmlBinaryWriterSession instance is one of them. When XmlDictionaryWriter is used with the DataContractSerializer with which it was intended to be used, everything works as expected. The instance of XmlBinaryWriterSession provides logic for generating dynamic dictionary and the resulted serialized data looks right with all XML tags "binarized".

On the other hand XmlDictionaryWriter inherited from XmlWriter and I would expect the same or similar result calling XDocument instance Save method but it is completely different. It is as if XmlBinaryWriterSession is not used at all and the result is "semi-binary". XML tags are not dynamically translated. Is there a way to make XDocument to work with XmlDictionaryWriter in the same manner as DataContractSerializer works with it?

No comments:

Post a Comment