Example #1
0
        /// <summary>
        /// Perform a deep Copy of the object, using Json as a serialisation method.
        /// </summary>
        /// <typeparam name="T">The type of object being copied.</typeparam>
        /// <param name="source">The object instance to copy.</param>
        /// <returns>The copied object.</returns>
        public static T CloneJson <T>(this T source)
        {
            // Don't serialize a null object, simply return the default for that object
            if (Object.ReferenceEquals(source, null))
            {
                return(default(T));
            }

            return(ObjectSerialization.Deserialize <T>(ObjectSerialization.Serialize(source)));
        }
Example #2
0
 public static string SerializeProto(this object o)
 {
     return(ObjectSerialization.Serialize(o));
 }