Пример #1
0
 /// <summary>
 /// Writes a <paramref name="value"/> of type <typeparamref name="T"/> into <paramref name="destination"/>.
 /// </summary>
 /// <exception cref="IndexOutOfRangeException">Thrown if the <paramref name="value"/> does not fit into the <paramref name="destination"/>.</exception>
 public static void Write <T>(this IHFormat format, Span <byte> destination, T value, out int bytesWritten)
     where T : struct
 {
     if (!format.TryWrite(destination, value, out bytesWritten))
     {
         ThrowHelper.ThrowIndexOutOfRangeException();
     }
 }
Пример #2
0
 /// <summary>
 /// Writes the specified value type to the buffer.
 /// </summary>
 /// <param name="value">The value to write.</param>
 /// <typeparam name="T">The type of the value to write.</typeparam>
 public bool AppendFormatted <T>(T value)
     where T : unmanaged
 {
     if (_format.TryWrite(_destination.Slice(_position), value, out int bytesWritten))
     {
         _position += bytesWritten;
         return(true);
     }
     return(Fail());
 }