What is the best way to create a clone of a DTO? There is not an ICloneable interface or a BinaryFormatter class in Silverlight. Is reflection the only way?
相关问题
- Save html in cookie
- Clone a div that contains “customized” jQueryUI da
- How to create a “clone”-able enumerator for extern
- use case for clone()
- Queue.Clone method usage C#
相关文章
- spawn & drag of SVG elements - approach
- VB.NET Forced Inheritance through multiple generat
- Deep copy of Angular Reactive Form?
- Why String class is not Cloneable?
- How to clone an object in VB6
- JQuery AutoComplete and Clone
- Silverlight: Force Canvas to Invalidate or Repaint
- React createElement vs cloneElement
How to create clone if my source is IEnumerable. This LayerDto also has some object type(eg MetaItemDto).
Code :
public class LayerDto { }
public class MetaItemDtoList : System.Collections.ObjectModel.ObservableCollection { }
public static IEnumerable Clone(IEnumerable source)
{
}
but what is problem I am facing is that layer doesn't show it's metaItems(for every layer).
I believe the standard cloning functionality was left out to keep it simple and lightweight. I believe you could use either JSON or XML serialization to achieve the same thing though. Not sure about the performance costs though.
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. Help from Mike Schall code; it is working for me.
Here is the code we came up with for cloning. This works in Silverlight 2 & 3.