예제 #1
0
        /// <summary>
        /// Makes deep clone of object with all the nested objects and collections
        /// </summary>
        /// <param name="original">Original object</param>
        /// <returns>Object clone</returns>
        public static T DeepClone <T>(T original)
        {
            if (original == null)
            {
                return(original);
            }
            if (typeof(T).IsInlineCloning())
            {
                return(original);
            }
            if (original is ICloneable clon)
            {
                return((T)clon.Clone());
            }

            var dco = new DeepCloneOperator(_cloneDelegates);

            return((T)dco.MakeClone(original));
        }
예제 #2
0
        /// <summary>
        /// Makes deep clone of object with all the nested objects and collections
        /// </summary>
        /// <param name="original">Original object</param>
        /// <returns>Object clone</returns>
        public static object DeepClone(object original)
        {
            if (original == null)
            {
                return(null);
            }
            if (original.GetType().IsInlineCloning())
            {
                return(original);
            }
            if (original is ICloneable clon)
            {
                return(clon.Clone());
            }

            var dco = new DeepCloneOperator(_cloneDelegates);

            return(dco.MakeClone(original));
        }