MCPcopy Create free account
hub / github.com/FlaxEngine/FlaxEngine / DeepClone

Method DeepClone

Source/Engine/Utilities/Extensions.cs:26–31  ·  view source on GitHub ↗

Creates deep clone for a class if all members of this class are marked as serializable (uses Json serialization). The input instance of an object. The instance type of an object. Returns new object of provided class.

(this T instance)

Source from the content-addressed store, hash-verified

24 /// <typeparam name="T">The instance type of an object.</typeparam>
25 /// <returns>Returns new object of provided class.</returns>
26 public static T DeepClone<T>(this T instance)
27 where T : new()
28 {
29 var json = Json.JsonSerializer.Serialize(instance);
30 return (T)Json.JsonSerializer.Deserialize(json, instance.GetType());
31 }
32
33 /// <summary>
34 /// Creates raw clone for a structure using memory copy. Valid only for value types.

Callers 6

AddSplinePointMethod · 0.80
BuildAllFunction · 0.80
BuildFunction · 0.80
GatherDataFunction · 0.80
GatherDataMethod · 0.80
StyleEditorWindowMethod · 0.80

Calls 3

SerializeMethod · 0.45
DeserializeMethod · 0.45
GetTypeMethod · 0.45

Tested by

no test coverage detected