WCF雙工會話通道基本創(chuàng)建步驟詳解
作者:佚名
我們會在接下來的這篇文章中通過一段代碼的解讀來為大家分析一下WCF雙工會話通道的基本創(chuàng)建方法,希望可以給大家?guī)硪恍椭?/div>
WCF開發(fā)插件擁有非常大的功能優(yōu)勢,這些優(yōu)勢決定了其在開發(fā)領域中占據著一定的主導地位。我們今天就先從WCF雙工會話通道的基本概念開始了解,來對這一開發(fā)工具進行更加深入的了解。
從對象模型的角度來看,會話通道形狀與非會話通道只有一些細微的差別。例如,IDuplexSessionChannel是IDuplexChannel和 ISessionChannel<IDuplexSession>的結合體。因為我們已有有了一個DelegatorDuplexChannel類型定義(它實現了IDuplexChannel接口),創(chuàng)建一個WCF雙工會話通道僅僅是一個繼承DelegatorDuplexChannel并實現IDuplexSessionChannel接口的問題,如下所示:
- internal sealed class DelegatorDuplexSessionChannel :
DelegatorDuplexChannel, IDuplexSessionChannel- {
- private IDuplexSessionChannel _innerSessionChannel;
- // reference the next
- // sessionful channel
- private String _source;
- // store the String to output internal
- DelegatorDuplexSessionChannel(ChannelManagerBase
- channelManagerBase, IDuplexSessionChannel innerChannel, String source)
: base(channelManagerBase, innerChannel, source)- {
- _source = String.Format("{0} CHANNEL: DelegatorDuplexSessionChannel",
source);- PrintHelper.Print(_source, "ctor");
- // assign the reference to the next sessionful channel
- this._innerSessionChannel = innerChannel;
- }
- // IDuplexSessionChannel member that is not defined in IDuplexChannel
- public IDuplexSession Session
- {
- get {
- PrintHelper.Print(_source, "Session");
- return this._innerSessionChannel.Session;
- }
- }
- }
DelegatorDuplexChannel包含一個IDuplexChannel類型的成員變量,我們需要通過一個IDuplexSessionChannel類型的局部變量來存儲同一個對象的引用。這樣做可以使得我們容易地添加Session屬性到我們的類型定義上。
以上就是對WCF雙工會話通道的相關介紹。
【編輯推薦】
責任編輯:曹凱
來源:
CSDN


相關推薦
2010-03-01 09:48:23
2010-02-23 16:32:29
2010-02-26 16:10:50
2009-12-21 15:33:07
2010-03-01 16:31:58
2009-11-09 09:41:25
2009-11-05 16:12:09
2009-12-08 13:06:15
2010-02-25 15:25:19
2009-12-21 17:40:25
2010-03-11 13:54:01




