Free cookie consent management tool by TermsFeed Policy Generator

Changeset 4657


Ignore:
Timestamp:
10/29/10 13:44:15 (14 years ago)
Author:
swagner
Message:

Added typed clone method in Cloner (#922)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/CloningRefactoring/HeuristicLab.Common/3.3/Cloner.cs

    r4068 r4657  
    5050    }
    5151    /// <summary>
     52    /// Creates a deep clone of a given deeply cloneable object.
     53    /// </summary>
     54    /// <param name="item">The object which should be cloned.</param>
     55    /// <returns>A clone of the given object.</returns>
     56    public T Clone<T>(T obj) where T : class, IDeepCloneable {
     57      if (obj == null) return null;
     58      IDeepCloneable clone;
     59      if (mapping.TryGetValue(obj, out clone))
     60        return (T)clone;
     61      else
     62        return (T)obj.Clone(this);
     63    }
     64    /// <summary>
    5265    /// Registers a new clone for a given deeply cloneable object.
    5366    /// </summary>
Note: See TracChangeset for help on using the changeset viewer.