mirror of
https://github.com/RHeavenStudioPlus/HeavenStudioPlus.git
synced 2024-12-04 23:37:27 +00:00
1ed2291844
I spent about 6 hours trying to fix this one specific bug involving the move undo. Turns out all I had to do was calm down and think logically instead of typing random bullshit for a few hours until it worked. I'm tired and I thank this for ruining my sleep schedule.
18 lines
No EOL
450 B
C#
18 lines
No EOL
450 B
C#
using System;
|
|
using System.IO;
|
|
using System.Runtime.Serialization.Formatters.Binary;
|
|
|
|
public static class Extensions
|
|
{
|
|
public static T DeepClone<T>(this T obj)
|
|
{
|
|
using (MemoryStream stream = new MemoryStream())
|
|
{
|
|
BinaryFormatter formatter = new BinaryFormatter();
|
|
formatter.Serialize(stream, obj);
|
|
stream.Position = 0;
|
|
|
|
return (T)formatter.Deserialize(stream);
|
|
}
|
|
}
|
|
} |