开发者

How to Serializer IEnumerable Object in silverlight

开发者 https://www.devze.com 2023-04-12 23:06 出处:网络
ICloneable is not available in Silverlight 4(I don\'t know about 1/2/3 or upcoming version) . It is removed from Silverlight 4\'s public APIs.

ICloneable is not available in Silverlight 4(I don't know about 1/2/3 or upcoming version) . It is removed from Silverlight 4's public APIs.

I have these classes :

public class LayerDto 

{

public MetaItemDtoList MetaItems;

}

public class MetaItemDtoList : System.Collections.ObjectModel.ObservableCollection 
{ 
}

I want to create clone of IEnumerable<LayerDto>. I am trying to do this. but not getting metaItems

public static IEnumerable Clone(IEnumerable<LayerDto> source)

{
        IEnumerable<LayerDto> layers;

        DataContractSerializer serializer = new DataContractSerializer(typeof(IEnumerable<LayerDto>));
   开发者_C百科     using (MemoryStream ms = new MemoryStream())
        {
            serializer.WriteObject(ms, source);
            ms.Seek(0, SeekOrigin.Begin);
            //return (IEnumerable<LayerDto>)serializer.ReadObject(ms);
            layers = (IEnumerable<LayerDto>)serializer.ReadObject(ms);
            return layers;
        }
 }
0

精彩评论

暂无评论...
验证码 换一张
取 消