24 lines
573 B
C#
24 lines
573 B
C#
|
using System.Text;
|
||
|
using InnovEnergy.Lib.Utils;
|
||
|
|
||
|
namespace InnovEnergy.Logging;
|
||
|
|
||
|
public static class Extensions
|
||
|
{
|
||
|
private const Char NewLine = '\n';
|
||
|
|
||
|
public static Byte[] Serialize(this Exception e)
|
||
|
{
|
||
|
return Encoding.UTF8.GetBytes(e.Message + NewLine + e);
|
||
|
}
|
||
|
|
||
|
public static (String title, String message) Deserialize(this IReadOnlyList<Byte> data)
|
||
|
{
|
||
|
var strData = data
|
||
|
.ToArray()
|
||
|
.Apply(Encoding.UTF8.GetString);
|
||
|
|
||
|
return (strData.UntilFirst(NewLine), strData.AfterFirst(NewLine));
|
||
|
}
|
||
|
|
||
|
}
|