WCF中有哪些集合類型

這篇文章給大家介紹WCF中有哪些集合類型,內(nèi)容非常詳細(xì),感興趣的小伙伴們可以參考借鑒,希望對(duì)大家能有所幫助。

創(chuàng)新互聯(lián)公司是一家專業(yè)提供龍華企業(yè)網(wǎng)站建設(shè),專注與成都網(wǎng)站設(shè)計(jì)、做網(wǎng)站成都h5網(wǎng)站建設(shè)、小程序制作等業(yè)務(wù)。10年已為龍華眾多企業(yè)、政府機(jī)構(gòu)等服務(wù)。創(chuàng)新互聯(lián)專業(yè)網(wǎng)站制作公司優(yōu)惠進(jìn)行中。

WCF自定義集合類型,如果作為服務(wù)契約的一部分進(jìn)行發(fā)布,必須要保證以下幾點(diǎn):WCF集合包含的類型必須使用[Serializable]和[DataContract]標(biāo)記;WCF集合包含的類型屬性必須使用[DataMember]標(biāo)記,并且,如果是屬性(Property),必須要實(shí)現(xiàn)get和set;WCF集合類型必須使用[Serializable]和[CollectionDataContract]標(biāo)記,以及[KnownType]標(biāo)記指向集合包含的子類型;集合類型必須實(shí)現(xiàn)IEnumerable<T>接口;集合類型使用[DataMember]標(biāo)記的IList將集合項(xiàng)向客戶端公開.

樣例如下:

namespaceSharpnessdotnet  {  [Serializable]  [DataContract]  publicclassSharpnessdotnet  {  privatestringname;  [DataMember]  publicstringName  {  get  {  returnname;  }  set  {  name=value;  }  }  }  [Serializable]  [CollectionDataContract]  [KnownType(typeof(Sharpnessdotnet))]  publicclassSharpnessdotentCollection:IEnumerable<Sharpnessdotnet> {  [DataMember]  publicIList<Sharpnessdotnet>List;  publicSharpnessdotentCollection()  {  List=newList<Sharpnessdotnet>();  }  publicvoidAdd(Sharpnessdotnetobj)  {  List.Add(obj);  }  publicIEnumerator<Sharpnessdotnet>GetEnumerator()  {  returnList.GetEnumerator();  }   IEnumeratorIEnumerable.GetEnumerator()  {  returnList.GetEnumerator();  }  }  }

關(guān)于WCF中有哪些集合類型就分享到這里了,希望以上內(nèi)容可以對(duì)大家有一定的幫助,可以學(xué)到更多知識(shí)。如果覺得文章不錯(cuò),可以把它分享出去讓更多的人看到。

分享標(biāo)題:WCF中有哪些集合類型
網(wǎng)頁網(wǎng)址:http://muchs.cn/article30/ihdcpo.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供云服務(wù)器、網(wǎng)站收錄企業(yè)建站、外貿(mào)網(wǎng)站建設(shè)、、App設(shè)計(jì)

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)

外貿(mào)網(wǎng)站建設(shè)