コード例 #1
0
        private byte[] JustSerialize(object value, out uint flag)
        {
            using var builder = new SequenceBuilder(MemoryPool <byte> .Shared);
            var t = new BinaryItemFormatter();

            flag = t.Serialize(builder, value);

            return(builder.Commit().ToArray());
        }
コード例 #2
0
		public void Commit()
		{
			try { finalBody = bodyBuilder.Commit(); }
			catch (Exception e)
			{
				bodyBuilder.Dispose();

				throw new InvalidOperationException("Fatal exception: could not build the binary request. See the inner exception for details.", e);
			}
		}
コード例 #3
0
        public void KeyFormatterTests(string input)
        {
            var transformer = new Utf8KeyFormatter();

            using var builder = new SequenceBuilder(MemoryPool <byte> .Shared);
            transformer.Serialize(builder, input);

            var expected = new UTF8Encoding(false).GetBytes(input);

            Assert.Equal(expected, builder.Commit().ToArray());
        }
コード例 #4
0
        public void KeyFormatterTests(string prefix, string key)
        {
            var transformer = new NamespacingKeyFormatter(prefix);

            using var builder = new SequenceBuilder(MemoryPool <byte> .Shared);
            transformer.Serialize(builder, key);

            var expected = new UTF8Encoding(false).GetBytes(prefix + key);

            Assert.Equal(expected, builder.Commit().ToArray());
        }