Additional static functions used to extend existing Memory support inside of Unity.
More...
Additional static functions used to extend existing Memory support inside of Unity.
Definition at line 39 of file Memory.cs.
static T Hydrogen.Memory.Clone< T > |
( |
this T |
source | ) |
|
|
static |
Perform a deep Copy of the object.
- Returns
- The copied object.
- Template Parameters
-
- Parameters
-
source | The object instance to copy. |
Definition at line 47 of file Memory.cs.
49 if (!typeof(T).IsSerializable) {
50 throw new ArgumentException (
"The type must be serializable.",
"source");
54 if (Object.ReferenceEquals (source, null)) {
58 IFormatter formatter =
new BinaryFormatter ();
59 Stream stream =
new MemoryStream ();
61 formatter.Serialize (stream, source);
62 stream.Seek (0, SeekOrigin.Begin);
63 return (T)formatter.Deserialize (stream);