/// <summary> /// Writes the provided <see cref="bytes"/>. /// </summary> /// <param name="writable"></param> /// <param name="bytes">The bytes to write.</param> public static void Write(this IBytesWrittable writable, byte[] bytes) { if (writable == null) { throw new ArgumentNullException(nameof(writable)); } writable.Write(bytes, 0, bytes.Length); }
/// <summary> /// Writes the provided <see cref="bytes"/> asyncronously. /// </summary> /// <param name="writable"></param> /// <param name="bytes">The bytes to write.</param> /// <returns>An awaitable task.</returns> public static Task WriteAsync(this IBytesWrittable writable, byte[] bytes) { if (writable == null) { throw new ArgumentNullException(nameof(writable)); } return(writable.WriteAsync(bytes, 0, bytes.Length)); }
/// <summary> /// Writes the provided <see cref="bytes"/> starting at the <see cref="offset"/> /// for <see cref="count"/> many bytes. /// </summary> /// <param name="writable"></param> /// <param name="bytes">The bytes to write.</param> /// <param name="offset">The offset to start at.</param> /// <param name="count">The amount of bytes to write.</param> public static void Write(this IBytesWrittable writable, byte[] bytes, int offset, int count) { if (writable == null) { throw new ArgumentNullException(nameof(writable)); } //TODO: Should we block here? writable.WriteAsync(bytes, offset, count); }