LINQ to XML X-DOM 内部实现
System.Xml.Linq
命名空间中的 LINQ to XML X-DOM 在内部是如何实现的? (XNode、XElement 等)
它是否利用来自其他 XML 命名空间或其他名称的标准高性能单向 XmlReader/XmlWriter?
我问的原因是我试图找出在哪些情况下可以或应该使用,因为性能始终是一个问题。
How is the LINQ to XML X-DOM from the System.Xml.Linq
namespace internally implemented? (XNode, XElement, etc.)
Is it utilizing standard high-performing one-way XmlReader/XmlWriter from the other XML namespaces or something else?
The reason I'm asking is that I'm trying to figure out in which circumstances could or should be used as performance is always a concern.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用 Reflector(或者,当不再免费时,ILSpy :);不,我不是员工 - 只是偷偷传播消息!)似乎所有加载/保存方法都通过
XmlReader
和XmlWriter
进行传输。例如,XElement 的 Load(Stream, LoadOptions) 实现是这样做的:
对于所有其他静态方法(包括 Parse)来说,情况都是类似的。
但是还有
XStreamingElement
构造函数 - 但是我在XElement
类本身之外找不到它的任何实际用法。看起来这可能是一种优化的加载类型,但到目前为止,还没有被太多使用。同样,Save 和 WriteTo 方法最终使用
XmlWriter
实例 - 例如:因此至少从性能的角度来看,它们从正确的类型开始:)
Using Reflector (or, when that's no longer free, ILSpy :); no I'm not an employee - just spreading the word surreptitiously!) it appears all the load/save methods channel through to
XmlReader
andXmlWriter
.For example - XElement's implementation of
Load(Stream, LoadOptions)
does this:And it's a similar story for all the other static methods - including Parse.
But then there is the
XStreamingElement
constructor - however I can't find any real usage of it outside of theXElement
class itself. Looks like this could be an optimised type for loading that, as yet, isn't used by much.Equally, the Save and WriteTo methods ultimately use an
XmlWriter
instance - e.g:So at least from a performance point of view they started with the right types :)