WCF雙工會話通道基本創(chuàng)建步驟詳解
作者:佚名
我們會在接下來的這篇文章中通過一段代碼的解讀來為大家分析一下WCF雙工會話通道的基本創(chuàng)建方法,希望可以給大家?guī)硪恍椭?/div>
WCF開發(fā)插件擁有非常大的功能優(yōu)勢,這些優(yōu)勢決定了其在開發(fā)領(lǐng)域中占據(jù)著一定的主導(dǎo)地位。我們今天就先從WCF雙工會話通道的基本概念開始了解,來對這一開發(fā)工具進(jìn)行更加深入的了解。
從對象模型的角度來看,會話通道形狀與非會話通道只有一些細(xì)微的差別。例如,IDuplexSessionChannel是IDuplexChannel和 ISessionChannel<IDuplexSession>的結(jié)合體。因為我們已有有了一個DelegatorDuplexChannel類型定義(它實現(xiàn)了IDuplexChannel接口),創(chuàng)建一個WCF雙工會話通道僅僅是一個繼承DelegatorDuplexChannel并實現(xiàn)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類型的局部變量來存儲同一個對象的引用。這樣做可以使得我們?nèi)菀椎靥砑覵ession屬性到我們的類型定義上。
以上就是對WCF雙工會話通道的相關(guān)介紹。
【編輯推薦】
責(zé)任編輯:曹凱
來源:
CSDN


相關(guān)推薦
2009-12-21 15:33:07
2009-11-09 09:41:25




