C#扩展的SoapExtension - [英] C# extending SoapExtension -

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

问题描述

背景:
我试图写一个简单的SoapExtension类从ASMX Web服务记录呼入/呼出的SOAP消息。继这篇文章在MSDN上,我已经能够得到的东西的工作。不过,我真的很想知道它为什么/如何工作的,而不仅仅是复制和放大器; 。粘贴代码

Background: I'm trying to write a simple SoapExtension class to log inbound/outbound Soap messages from an asmx web service. Following this article on msdn, I have been able to get things working. However I'd really like to understand why/how it's working rather than just copy & pasting code.

的问题:
我有点吃力我具体把握是IO的处理中的示例流。我已经在网络上阅读的所有其他条款处理流以相同的方式......先取到原始流的引用,创建一个在内存中的工作流,然后根据需要交换的内容。

The question: What I'm stuggling to grasp specifically is the handling of the IO streams in the example. All other articles I've read on the web handle the streams in an identical way... first getting a reference to the original stream, creating an in memory "working" stream, and then swapping the contents as necessary.

首先的问题是,什么是在这种情况下流链是什么意思?我流的understaning是写任何流将自动写入到一个管道中的'内部'流。如果是这样的话,为什么需要手动从一个流的内容复制到另一个?

First question is, what is meant by "stream chaining" in this context? My understaning of streams is that writing to any stream will automatically write to the 'inner' streams in a pipeline. If that's the case, why is it necessary to manually copy contents from one stream to another?

第二个问题是,在示例复制方法,他们正在创造一个StreamReader和StreamWriter的每一次,不设置他们 - 这是不把GC上的额外的压力?似乎并不像你想在一个高流量的网络服务的东西......我想无论包装使用的语句,但处理读/写器也被关闭而导致更严重的错误流。 .NET 4的新Stream.CopyTo(流)的方法,但是这将是对.NET 3.5?

Second question is, in the examples Copy method they're creating a StreamReader and StreamWriter each time, without disposing them - is this not putting extra pressure on the GC? Doesn't seem like something you'd want on a high traffic web service... I tried wrapping both in using statements, but disposing the reader/writer also closed the stream which led to more serious errors. .NET 4 has new Stream.CopyTo(Stream) methods, but what would be a better approach for .NET 3.5?

推荐答案

更好的方法好了,通过级联流可以基本有做不同的事情,在链序列不同的数据流。例如,可以有一个流是压缩数据,然后该加密的数据(或者,如果我们在其他方向移动的对面)另一个流

Well, by chaining streams you can basically have different streams that do different things, in a chained sequence. For instance, you can have one stream that compresses the data, and then another stream that encrypts the data (or the opposite if we are moving in the other direction).

至于ChainStream本身,嗯...有很多东西,说这一个。我真的建议这篇文章名为 内的rel=\"nofollow\" title=\"Inside ,这是非常深入的,也涵盖了大部分的你有问题。

As for ChainStream itself, well... There are lots of things to say about this one. I really recommend this article called Inside of Chainstream, which is extremely in-depth and also covers most of the questions you have.

这篇关于C#扩展的SoapExtension - 的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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