|
using System.IO;
using System.Runtime.Serialization.Formatters.Binary;
namespace CodeProject.VisualStudio.QualityTools.UnitTestFramework
{
public static class TestExtensions
{
public static T SerializeClone<T>(this T self) where T : class
{
using (MemoryStream stream = new MemoryStream())
{
BinaryFormatter formatter = new BinaryFormatter();
formatter.Serialize(stream, self);
stream.Seek(0, SeekOrigin.Begin);
return formatter.Deserialize(stream) as T;
}
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
Windows developer with 10+ years experience working in the banking industry.