public byte[] Serialize <T>(T obj, string?mimeType = null) { var activity = MessageDiagnostics.StartMessageSerialize(); var serializer = GetSerializer(mimeType); var result = serializer.Serialize(obj); MessageDiagnostics.StopMessageSerialize(activity); return(result); }
public List <byte[]> SerializeBatch <T>(IEnumerable <T> enumerable, string?mimeType = null) { var activity = MessageDiagnostics.StartMessageSerialize(); var serializer = GetSerializer(mimeType); var list = new List <byte[]>(); foreach (var item in enumerable) { list.Add(serializer.Serialize(item)); } MessageDiagnostics.StopMessageSerialize(activity); return(list); }