mirror of https://github.com/Squidex/squidex.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
30 lines
976 B
30 lines
976 B
// ==========================================================================
|
|
// Squidex Headless CMS
|
|
// ==========================================================================
|
|
// Copyright (c) Squidex UG (haftungsbeschraenkt)
|
|
// All rights reserved. Licensed under the MIT license.
|
|
// ==========================================================================
|
|
|
|
using System.IO;
|
|
using System.Runtime.Serialization.Formatters.Binary;
|
|
|
|
#pragma warning disable SYSLIB0011 // Type or member is obsolete
|
|
|
|
namespace Squidex.Infrastructure.TestHelpers
|
|
{
|
|
public static class BinaryFormatterHelper
|
|
{
|
|
private static readonly BinaryFormatter Formatter = new BinaryFormatter();
|
|
|
|
public static T SerializeAndDeserializeBinary<T>(this T source)
|
|
{
|
|
var stream = new MemoryStream();
|
|
|
|
Formatter.Serialize(stream, source!);
|
|
|
|
stream.Position = 0;
|
|
|
|
return (T)Formatter.Deserialize(stream);
|
|
}
|
|
}
|
|
}
|
|
|