ICloneable在Silverlight 4中不可用(我不知道1/2/3或即将推出的版本)。它已从Silverlight 4的公共API中删除。
我有这些课程:
public class LayerDto
{
public MetaItemDtoList MetaItems;
}
public class MetaItemDtoList : System.Collections.ObjectModel.ObservableCollection
{
}
我想创建IEnumerable<LayerDto>
的克隆。
我想这样做。但没有得到metaItems
public static IEnumerable Clone(IEnumerable<LayerDto> source)
{
IEnumerable<LayerDto> layers;
DataContractSerializer serializer = new DataContractSerializer(typeof(IEnumerable<LayerDto>));
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;
}
}