public Stream WriteData() { CloseNotifyingMemoryStream stream = new CloseNotifyingMemoryStream(); stream.Closing += (s, ea) => { _message.Data = stream.ToArray(); }; return(stream); }
/// <inheritdoc/> public Task <Stream> WriteData() { CloseNotifyingMemoryStream stream = new CloseNotifyingMemoryStream(); stream.Closing += (s, ea) => { this.message.Data = stream.ToArray(); }; return(Task.FromResult <Stream>(stream)); }
public override Stream GetData(DataAccessMode dataAccessMode) { if (dataAccessMode == DataAccessMode.ForWriting) { CloseNotifyingMemoryStream stream = new CloseNotifyingMemoryStream(); stream.Closing += (s, ea) => { _data = new byte[stream.Length]; stream.Position = 0; stream.Read(_data, 0, _data.Length); }; return(stream); } else { return(new MemoryStream(_data, false)); } }
public Stream GetData(bool forWriting) { if (forWriting) { CloseNotifyingMemoryStream stream = new CloseNotifyingMemoryStream(); stream.Closing += (s, ea) => { _data = new byte[stream.Length]; stream.Position = 0; stream.Read(_data, 0, _data.Length); }; return(stream); } else { return(new MemoryStream(_data, false)); } }