Innovenergy_trunk/csharp/app/Logging/Extensions.cs

24 lines
573 B
C#
Raw Normal View History

2023-02-16 12:57:06 +00:00
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));
}
}