自拍偷在线精品自拍偷,亚洲欧美中文日韩v在线观看不卡

快速上手篇之WCF自定義集合

開發(fā) 后端
文章主要介紹了如何定義集合元素類和WCF自定義集合DocumentList則實(shí)現(xiàn)了IList接口,希望對(duì)大家有幫助。

學(xué)習(xí)WCF時(shí),你可能會(huì)遇到WCF自定義集合問題,這里將介紹WCF自定義集合問題的解決方法,在這里拿出來和大家分享一下。對(duì)于一個(gè)好的分布式系統(tǒng)來講,設(shè)計(jì)時(shí)應(yīng)當(dāng)考慮到異構(gòu)性、開放性、安全性、可擴(kuò)展性、故障處理、并發(fā)性以及透明性等問題?;赟OAP的Web Service可以實(shí)現(xiàn)異構(gòu)環(huán)境的互操作性,保證了跨平臺(tái)的通信。

#T#利用WSE(Web Service Enhancements)可以為ASMX提供安全性的保證。.NET Remoting具有豐富的擴(kuò)展功能,可以創(chuàng)建定制的信道、格式化器和代理程序。Enterprise Service(COM+)提供了對(duì)事務(wù)的支持,其中還包括分布式事務(wù),可實(shí)現(xiàn)故障的恢復(fù)。MSMQ可以支持異步調(diào)用、脫機(jī)連接、斷點(diǎn)連接等功能,利用消息隊(duì)列支持應(yīng)用程序之間的消息傳遞。從功能角度來看,WCF整合了ASMX、.Net Remoting、Enterprise Service、WSE以及MSMQ等現(xiàn)有技術(shù)的優(yōu)點(diǎn),它提供了一種構(gòu)建安全可靠的分布式面向服務(wù)系統(tǒng)的統(tǒng)一的框架模型,使軟件研發(fā)人員在開發(fā)分布式應(yīng)用時(shí)變得更加輕松。

集合元素類的定義如下:

  1. public enum FileType  
  2. {  
  3. TXT,DOC,HTML,OTHER  
  4. }  
  5. [DataContract]  
  6. public class Document  
  7. {  
  8. private string m_localPath;  
  9. private string m_fileName;  
  10. private FileType m_fileType;         
  11.  
  12. [DataMember]  
  13. public string LocalPath  
  14. {  
  15. get { return m_localPath; }  
  16. set { m_localPath = value; }  
  17. }  
  18.  
  19. [DataMember]  
  20. public string FileName  
  21. {  
  22. get { return m_fileName; }  
  23. set { m_fileName = value; }  
  24. }  
  25. [DataMember]  
  26. public FileType FileType  
  27. {  
  28. get { return m_fileType; }  
  29. set { m_fileType = value; }  
  30. }  
  31.  
  32. }  

WCF自定義集合DocumentList則實(shí)現(xiàn)了IList接口:

  1. //which attribute should be applied here?  
  2. public class DocumentList:IList  
  3. {  
  4. private IList m_list = null;  
  5.  
  6. public DocumentList()  
  7. {  
  8. m_list = new List();  
  9. }  
  10.  
  11. #region IList Members  
  12.  
  13. public int IndexOf(Document item)  
  14. {  
  15. return m_list.IndexOf(item);  
  16. }  
  17.  
  18. public void Insert(int index, Document item)  
  19. {  
  20. m_list.Insert(index,item);  
  21. }  
  22.  
  23. public void RemoveAt(int index)  
  24. {  
  25. m_list.RemoveAt(index);  
  26. }  
  27.  
  28. public Document this[int index]  
  29. {  
  30. get  
  31. {  
  32. return m_list[index];  
  33. }  
  34. set  
  35. {  
  36. m_list[index] = value;  
  37. }  
  38. }  
  39.  
  40. #endregion  
  41.  
  42. #region ICollection Members  
  43.  
  44. public void Add(Document item)  
  45. {  
  46. m_list.Add(item);  
  47. }  
  48.  
  49. public void Clear()  
  50. {  
  51. m_list.Clear();  
  52. }  
  53.  
  54. public bool Contains(Document item)  
  55. {  
  56. return m_list.Contains(item);  
  57. }  
  58.  
  59. public void CopyTo(Document[] array, int arrayIndex)  
  60. {  
  61. m_list.CopyTo(array,arrayIndex);  
  62. }  
  63. public int Count  
  64. {  
  65. get { return m_list.Count; }  
  66. }  
  67. public bool IsReadOnly  
  68. {  
  69. get { return m_list.IsReadOnly; }  
  70. }  
  71. public bool Remove(Document item)  
  72. {  
  73. return m_list.Remove(item);  
  74. }  
  75. #endregion  
  76. #region IEnumerable Members  
  77. public IEnumerator GetEnumerator()  
  78. {  
  79. return m_list.GetEnumerator();  
  80. }  
  81. #endregion  
  82. #region IEnumerable Members  
  83. IEnumerator IEnumerable.GetEnumerator()  
  84. {  
  85. return ((IEnumerable)m_list).GetEnumerator();  
  86. }  
  87. #endregion  
  88. }  
責(zé)任編輯:田樹 來源: 博客
相關(guān)推薦

2010-03-01 09:56:21

WCF自定義集合類型

2009-07-06 13:49:29

2009-12-22 11:29:27

WCF自定義集合類型

2023-02-04 18:19:39

2009-11-05 09:51:14

WCF基礎(chǔ)

2010-02-25 16:27:44

WCF擴(kuò)展點(diǎn)

2010-02-25 11:23:29

WCF返回自定義格式

2010-03-01 11:10:41

WCF綁定元素

2010-02-24 14:59:52

WCF自定義過濾器

2009-11-06 16:48:03

WCF簡介

2010-03-02 18:01:07

WCF自定義消息篩選器

2025-01-17 07:00:00

2022-02-24 07:56:42

開發(fā)Viteesbuild

2021-10-26 10:07:02

鴻蒙HarmonyOS應(yīng)用

2011-08-02 11:17:13

iOS開發(fā) View

2022-06-30 14:02:07

鴻蒙開發(fā)消息彈窗組件

2022-07-15 16:45:35

slider滑塊組件鴻蒙

2015-02-12 15:33:43

微信SDK

2015-02-11 17:49:35

Android源碼自定義控件

2023-08-10 17:14:52

鴻蒙自定義彈窗
點(diǎn)贊
收藏

51CTO技術(shù)棧公眾號(hào)