XMLWriter的VS的XmlDictionaryWriter [英] XMLWriter vs XMLDictionaryWriter

查看:172
本文介绍了XMLWriter的VS的XmlDictionaryWriter的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

什么是之间的 XMLWriter的的XmlDictionaryWriter 的区别?在这情况下,是每一个通常使用?

What's the difference between XMLWriter and XMLDictionaryWriter? In which cases is each one generally used?

推荐答案

的XmlWriter是一个抽象类,其中的XmlDictionaryWriter是继承自它的类之一,是一个抽象类。

XmlWriter is an abstract class of which XmlDictionaryWriter is one of the classes that inherits from it and is itself an abstract class.

我在考虑要使用它与DataContractSerializer的或与德/序列化,一般黑暗中刺。该的XmlDictionaryWriter是使用WCF来完成其德/序列化的基类。

I am taking a stab in the dark that you want to use it with the DataContractSerializer or with de/serialization in general. The XmlDictionaryWriter is the base class used by WCF to do its de/serialization.

这是我推断,必须有在的XmlDictionaryWriter一些性能优化,使之更高性能与WCF德/序列化任务。如果您拨打的writeObject(流,对象)的事实,而不是的writeObject(XmlWriter的,对象)或的writeObject(的XmlDictionaryWriter,对象)方法,它会创建的XmlDictionaryWriter为您

From that I would deduce that there must be some performance tuning in the XmlDictionaryWriter to make it more performant with WCF de/serialization tasks. In fact if you call the WriteObject(Stream, object) instead of WriteObject(XmlWriter, object) or WriteObject(XmlDictionaryWriter, object) methods it will create an XmlDictionaryWriter for you

public virtual void WriteObject(Stream stream, object graph)
{
    CheckNull(stream, "stream");
    XmlDictionaryWriter writer = XmlDictionaryWriter.CreateTextWriter(stream, Encoding.UTF8, false);
    this.WriteObject(writer, graph);
    writer.Flush();
}

这篇关于XMLWriter的VS的XmlDictionaryWriter的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆