/// <summary> /// Creates a new <see cref="ITriflesByteWriter"/> backed by this sink. /// </summary> /// <param name="sink">A sink to convert.</param> /// <returns> /// A new <see cref="ITriflesByteWriter"/> whose <see cref="ITriflesByteWriter.Write(byte[], /// int, int)"/> method is implemented directly by the sink's <see /// cref="BinaryWriter.Write(byte[], int, int)"/> method. /// </returns> /// <exception cref="ArgumentNullException"><paramref name="sink"/> is <c>null</c>.</exception> public static ITriflesByteWriter ToTriflesByteWriter(this BinaryWriter sink) { return(TriflesByteWriterImpl.ToTriflesByteWriter(sink)); }
/// <summary> /// Creates a new <see cref="ITriflesByteWriter"/> backed by this sink. /// </summary> /// <param name="sink">A sink to convert.</param> /// <returns> /// A new <see cref="ITriflesByteWriter"/> whose <see cref="ITriflesByteWriter.Write(byte[], /// int, int)"/> method is implemented directly by the sink's <see cref="Stream.Write(byte[], /// int, int)"/> method. /// </returns> /// <exception cref="ArgumentNullException"><paramref name="sink"/> is <c>null</c>.</exception> /// <exception cref="ArgumentException"><paramref name="sink"/> does not support writing.</exception> public static ITriflesByteWriter ToTriflesByteWriter(this Stream sink) { return(TriflesByteWriterImpl.ToTriflesByteWriter(sink)); }
/// <summary> /// Writes blocks of bytes to the current sink using data read from a list. /// </summary> /// <param name="sink"></param> /// <param name="source"></param> /// <param name="offset"></param> /// <param name="count"></param> /// <param name="bufferSize"> /// The size of the temporary buffer used to copy elements from the provided source. /// </param> public static void Write(this BinaryWriter sink, IList <byte> source, int offset, int count, int bufferSize = 0) { TriflesByteWriterImpl.Write(sink.ToTriflesByteWriter(), source, offset, count, bufferSize); }
/// <summary> /// Writes blocks of bytes to the current sink using data read from a sequence. /// </summary> /// <param name="sink"></param> /// <param name="source"></param> /// <param name="bufferSize"> /// The size of the temporary buffer used to copy elements from the provided source. /// </param> public static void Write(this BinaryWriter sink, IEnumerable <byte> source, int bufferSize = 0) { TriflesByteWriterImpl.Write(sink.ToTriflesByteWriter(), source, bufferSize); }
/// <summary> /// Writes blocks of bytes to the current sink using data read from a list. /// </summary> /// <param name="sink"></param> /// <param name="source"></param> /// <param name="bufferSize"> /// The size of the temporary buffer used to copy elements from the provided source. /// </param> public static void Write(this Stream sink, IList <byte> source, int bufferSize = 0) { TriflesByteWriterImpl.Write(sink.ToTriflesByteWriter(), source, bufferSize); }