コード例 #1
0
        /// <summary>
        /// A class that inherits from Clonable can implement this
        /// member to override the default cloning mechanism.
        /// </summary>
        /// <returns>A new object that is a copy of this instance.</returns>
        protected virtual object OnClone()
        {
            object returnValue = null;

            lock (this)
            {
                IObjectCloneFactory factory = ClonableFactory.GetFactory();
                returnValue = factory.CloneInstance(this);
            }

            return(returnValue);
        }
コード例 #2
0
 /// <summary>
 /// Sets the current factory for cloning objects. This value can be set directly
 /// or by referencing a NuGet package that implements the IObjectCloneFactory interface.
 /// </summary>
 /// <param name="factory"></param>
 public static void SetFactory(IObjectCloneFactory factory)
 {
     ClonableFactory.Factory = factory;
 }