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

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

新聞中心

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

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

目前成都創(chuàng)新互聯(lián)公司已為上千的企業(yè)提供了網(wǎng)站建設(shè)、域名、網(wǎng)絡(luò)空間、網(wǎng)站托管維護、企業(yè)網(wǎng)站設(shè)計、常德網(wǎng)站維護等服務(wù),公司將堅持客戶導(dǎo)向、應(yīng)用為本的策略,正道將秉承"和諧、參與、激情"的文化,與客戶和合作伙伴齊心協(xié)力一起成長,共同發(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,對SimpleChannelFactory和SimpleChannelListener的創(chuàng)建分別實現(xiàn)在兩個被重寫的方法中:BuildChannelFactory< TChannel>和BuildChannelListener< TChannel>中。此外還重寫了兩個額外的方法:Clone和GetProperty< T>,前者用于克隆一個新的綁定元素,后一個和定義在信道、信道管理器的同名方法一樣,用于獲取基于某種類型的屬性。

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


當(dāng)前標(biāo)題:如何對WCF綁定元素進行自定義操作
網(wǎng)頁網(wǎng)址:http://www.5511xx.com/article/dhpocgg.html