blob: fc47192798fda5bfc43683778ada7f22d47412bc (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
using System;
using System.Buffers;
using MessagePack.Formatters;
using Microsoft;
using Nerdbank.Streams;
namespace MessagePack
{
/// <summary>
/// Internal utilities and extension methods for various external types.
/// </summary>
internal static class Utilities
{
internal delegate void GetWriterBytesAction<TArg>(ref MessagePackWriter writer, TArg argument);
internal static byte[] GetWriterBytes<TArg>(TArg arg, GetWriterBytesAction<TArg> action)
{
var writer = new MessagePackWriter();
action(ref writer, arg);
writer.Flush();
return writer.WrittenBytes.ToArray();
}
}
}
|