using System;
using System.Text;
using xCommons.Extensions;
namespace xEventService.Extensions {
public static class XEventModelExtensions {
///
/// Convert an Object to bytes array for publishing
///
///
///
///
public static byte[] ToBody (this T source) {
//
var json = source
.ToJSON ();
//
var result = json
.ToBytes ();
//
return result;
}
///
/// Convert Recieved Bytes to Specific Type ...
///
///
///
///
public static T FromBody (this ReadOnlyMemory source) {
//
var jsonString = Encoding.UTF8
.GetString (
source.ToArray ()
);
var result = jsonString.FromJSON ();
//
return result;
}
}
}