public override Task <object> ReadFromStreamAsync(Type type, Stream readStream, HttpContent content, IFormatterLogger formatterLogger) { var taskSource = new TaskCompletionSource <object>(); try { taskSource.SetResult(HelperFormatter.ReadBytes(readStream)); } catch (Exception e) { taskSource.SetException(e); } return(taskSource.Task); }
public override Task WriteToStreamAsync(Type type, object value, Stream writeStream, HttpContent content, TransportContext transportContext) { var taskSource = new TaskCompletionSource <object>(); try { HelperFormatter.WriteBytes((byte[])value, writeStream); taskSource.SetResult(null); } catch (Exception e) { taskSource.SetException(e); } return(taskSource.Task); }