Streamlined the cloning API: whether a property-based clone is performed is no longer indicated through a parameter, but by calling the appropriate method
git-svn-id: file:///srv/devel/repo-conversion/nusu@245 d2e56fa2-650e-0410-a79f-9358c0239efd
This commit is contained in:
parent
0f2bb60ea5
commit
15300676ba
7 changed files with 277 additions and 177 deletions
|
|
@ -26,39 +26,74 @@ namespace Nuclex.Support.Cloning {
|
|||
public interface ICloneFactory {
|
||||
|
||||
/// <summary>
|
||||
/// Creates a deep clone of the specified object, also creating clones of all
|
||||
/// child objects being referenced
|
||||
/// Creates a shallow clone of the specified object, reusing any referenced objects
|
||||
/// </summary>
|
||||
/// <typeparam name="TCloned">Type of the object that will be cloned</typeparam>
|
||||
/// <param name="objectToClone">Object that will be cloned</param>
|
||||
/// <param name="usePropertyBasedClone">
|
||||
/// Whether to clone the object based on its properties only
|
||||
/// </param>
|
||||
/// <returns>A deep clone of the provided object</returns>
|
||||
/// <returns>A shallow clone of the provided object</returns>
|
||||
/// <remarks>
|
||||
/// A property-based clone is useful if you're using dynamically generated proxies,
|
||||
/// such as when working with entities returned by an ORM like NHibernate.
|
||||
/// When not using a property-based clone, internal proxy fields would be cloned
|
||||
/// and might cause problems with the ORM.
|
||||
/// Field-based clones are guaranteed to be complete - there will be no missed
|
||||
/// members. This type of clone is also able to clone types that do not provide
|
||||
/// a default constructor.
|
||||
/// </remarks>
|
||||
TCloned DeepClone<TCloned>(TCloned objectToClone, bool usePropertyBasedClone);
|
||||
TCloned ShallowFieldClone<TCloned>(TCloned objectToClone);
|
||||
|
||||
/// <summary>
|
||||
/// Creates a shallow clone of the specified object, reusing any referenced objects
|
||||
/// </summary>
|
||||
/// <typeparam name="TCloned">Type of the object that will be cloned</typeparam>
|
||||
/// <param name="objectToClone">Object that will be cloned</param>
|
||||
/// <param name="usePropertyBasedClone">
|
||||
/// Whether to clone the object based on its properties only
|
||||
/// </param>
|
||||
/// <returns>A shallow clone of the provided object</returns>
|
||||
/// <remarks>
|
||||
/// A property-based clone is useful if you're using dynamically generated proxies,
|
||||
/// such as when working with entities returned by an ORM like NHibernate.
|
||||
/// When not using a property-based clone, internal proxy fields would be cloned
|
||||
/// and might cause problems with the ORM.
|
||||
/// <para>
|
||||
/// A property-based clone is useful if you're using dynamically generated proxies,
|
||||
/// such as when working with entities returned by an ORM like NHibernate.
|
||||
/// When not using a property-based clone, internal proxy fields would be cloned
|
||||
/// and might cause problems with the ORM.
|
||||
/// </para>
|
||||
/// <para>
|
||||
/// Property-based clones require a default constructor because there's no guarantee
|
||||
/// that all fields will are assignable through properties and starting with
|
||||
/// an uninitialized object is likely to end up with a broken clone.
|
||||
/// </para>
|
||||
/// </remarks>
|
||||
TCloned ShallowClone<TCloned>(TCloned objectToClone, bool usePropertyBasedClone);
|
||||
TCloned ShallowPropertyClone<TCloned>(TCloned objectToClone);
|
||||
|
||||
/// <summary>
|
||||
/// Creates a deep clone of the specified object, also creating clones of all
|
||||
/// child objects being referenced
|
||||
/// </summary>
|
||||
/// <typeparam name="TCloned">Type of the object that will be cloned</typeparam>
|
||||
/// <param name="objectToClone">Object that will be cloned</param>
|
||||
/// <returns>A deep clone of the provided object</returns>
|
||||
/// <remarks>
|
||||
/// Field-based clones are guaranteed to be complete - there will be no missed
|
||||
/// members. This type of clone is also able to clone types that do not provide
|
||||
/// a default constructor.
|
||||
/// </remarks>
|
||||
TCloned DeepFieldClone<TCloned>(TCloned objectToClone);
|
||||
|
||||
/// <summary>
|
||||
/// Creates a deep clone of the specified object, also creating clones of all
|
||||
/// child objects being referenced
|
||||
/// </summary>
|
||||
/// <typeparam name="TCloned">Type of the object that will be cloned</typeparam>
|
||||
/// <param name="objectToClone">Object that will be cloned</param>
|
||||
/// <returns>A deep clone of the provided object</returns>
|
||||
/// <remarks>
|
||||
/// <para>
|
||||
/// A property-based clone is useful if you're using dynamically generated proxies,
|
||||
/// such as when working with entities returned by an ORM like NHibernate.
|
||||
/// When not using a property-based clone, internal proxy fields would be cloned
|
||||
/// and might cause problems with the ORM.
|
||||
/// </para>
|
||||
/// <para>
|
||||
/// Property-based clones require a default constructor because there's no guarantee
|
||||
/// that all fields will are assignable through properties and starting with
|
||||
/// an uninitialized object is likely to end up with a broken clone.
|
||||
/// </para>
|
||||
/// </remarks>
|
||||
TCloned DeepPropertyClone<TCloned>(TCloned objectToClone);
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue