I have come across the need to distinguish between the creation of a
deep and a shallow copy and with great interest I have read this
article:
http://blogs.msdn.com/brada/archive/...03/125427.aspx
This artivle seems to hint that I should not use System.IClonable but
instead define my own interface(s) for cloning. Now since this article
is rather old and since they did not obsolete IClonable there might be
a new "best practise".
How do I implement Cloning of objects correctly if I want to explicitly
distinguish between deep and shallow copies? Should I
a) use System.IClonable for deep copies and override
object.MemberwiseClone for shallow copies ?
b) define my own IClonable, for example like this:
interface IClonable <T>
{
/// <summary>
/// creates a deep or shallow copy of the current object
/// </summary>
/// <param name="deep">
/// if <c>true</c> a deep copy should be returned,
/// wich means that the copied object and all
/// objects referenced by the object are copied recursively
/// if <c>false</c>a shallow copy should be retruned,
/// wich means that only the top level references
/// are copied
///</param>
/// <returns>a deep or a shallow copy of the current
object</returns>
T Clone (bool deep);
}
c) do something else I did not think of yet ?