日韩无码专区无码一级三级片|91人人爱网站中日韩无码电影|厨房大战丰满熟妇|AV高清无码在线免费观看|另类AV日韩少妇熟女|中文日本大黄一级黄色片|色情在线视频免费|亚洲成人特黄a片|黄片wwwav色图欧美|欧亚乱色一区二区三区

RELATEED CONSULTING
相關(guān)咨詢
選擇下列產(chǎn)品馬上在線溝通
服務(wù)時(shí)間:8:30-17:00
你可能遇到了下面的問(wèn)題
關(guān)閉右側(cè)工具欄

新聞中心

這里有您想知道的互聯(lián)網(wǎng)營(yíng)銷解決方案
如何對(duì)WCF綁定元素進(jìn)行自定義操作

WCF開(kāi)發(fā)插件在開(kāi)發(fā)領(lǐng)域中占據(jù)著重要的位置。它可以幫助開(kāi)發(fā)人員輕松的實(shí)現(xiàn)一個(gè)安全性高及可跨平臺(tái)的企業(yè)級(jí)解決方案。接下來(lái),我們通過(guò)一個(gè)案例來(lái)演示如果自定義一個(gè)WCF綁定元素。通過(guò)該綁定元素來(lái)創(chuàng)建我們?cè)谏厦嬉粋€(gè)案例中創(chuàng)建的兩個(gè)自定義信道管理器:SimpleChannelFactory和SimpleChannelListener。按照上面的命名方式,我們把這個(gè)自定義綁定元素命名為:SimpleBindingElement,下面是整個(gè)SimpleBindingElement的定義:

目前成都創(chuàng)新互聯(lián)公司已為上千的企業(yè)提供了網(wǎng)站建設(shè)、域名、網(wǎng)絡(luò)空間、網(wǎng)站托管維護(hù)、企業(yè)網(wǎng)站設(shè)計(jì)、常德網(wǎng)站維護(hù)等服務(wù),公司將堅(jiān)持客戶導(dǎo)向、應(yīng)用為本的策略,正道將秉承"和諧、參與、激情"的文化,與客戶和合作伙伴齊心協(xié)力一起成長(zhǎng),共同發(fā)展。

 
 
 
  1. public class SimpleBindingElement : BindingElement   
  2. {   
  3. public SimpleBindingElement()   
  4. {   
  5. PrintHelper.Print(this, "SimpleBindingElement");   
  6. }   
  7. public override BindingElement Clone()   
  8. {   
  9. PrintHelper.Print(this, "Clone");   
  10. return new SimpleBindingElement();   
  11. }   
  12. public override T GetProperty< T>(BindingContext context)   
  13. {   
  14. PrintHelper.Print(this, string.Format("GetProperty< {0}>",
     typeof(T).Name));   
  15. return context.GetInnerProperty< T>();   
  16. }   
  17. public override IChannelFactory< TChannel> BuildChannelFactory
    < TChannel>(BindingContext context)   
  18. {   
  19. PrintHelper.Print(this, "BuildChannelFactory< TChannel>");   
  20. return new SimpleChannelFactory< TChannel>(context) as 
    IChannelFactory< TChannel>;   
  21. }   
  22. public override IChannelListener< TChannel> BuildChannelListener
    < TChannel>(BindingContext context)   
  23. {   
  24. PrintHelper.Print(this, "BuildChannelListener< TChannel>");   
  25. return new SimpleChannelListener< TChannel>(context) as 
    IChannelListener< TChannel>;   
  26. }   

SimpleBindingElement直接繼承自抽象的基類BindingElement,對(duì)SimpleChannelFactory和SimpleChannelListener的創(chuàng)建分別實(shí)現(xiàn)在兩個(gè)被重寫(xiě)的方法中:BuildChannelFactory< TChannel>和BuildChannelListener< TChannel>中。此外還重寫(xiě)了兩個(gè)額外的方法:Clone和GetProperty< T>,前者用于克隆一個(gè)新的綁定元素,后一個(gè)和定義在信道、信道管理器的同名方法一樣,用于獲取基于某種類型的屬性。

WCF綁定元素的相關(guān)自定義操作方法就為大家介紹到這里。


名稱欄目:如何對(duì)WCF綁定元素進(jìn)行自定義操作
轉(zhuǎn)載源于:http://m.5511xx.com/article/dhpocgg.html