Esempio n. 1
0
 public override async Task<TMap> ReadMapBeginAsync(CancellationToken cancellationToken)
 {
     var map = new TMap();
     await ReadJsonArrayStartAsync(cancellationToken);
     map.KeyType = GetTypeIdForTypeName(await ReadJsonStringAsync(false, cancellationToken));
     map.ValueType = GetTypeIdForTypeName(await ReadJsonStringAsync(false, cancellationToken));
     map.Count = (int) await ReadJsonIntegerAsync(cancellationToken);
     await ReadJsonObjectStartAsync(cancellationToken);
     return map;
 }
Esempio n. 2
0
 public override async Task WriteMapBeginAsync(TMap map, CancellationToken cancellationToken)
 {
     await WriteJsonArrayStartAsync(cancellationToken);
     await WriteJsonStringAsync(GetTypeNameForTypeId(map.KeyType), cancellationToken);
     await WriteJsonStringAsync(GetTypeNameForTypeId(map.ValueType), cancellationToken);
     await WriteJsonIntegerAsync(map.Count, cancellationToken);
     await WriteJsonObjectStartAsync(cancellationToken);
 }
Esempio n. 3
0
        public override async Task WriteMapBeginAsync(TMap map, CancellationToken cancellationToken)
        {
            if (cancellationToken.IsCancellationRequested)
            {
                return;
            }

            if (map.Count == 0)
            {
                await Trans.WriteAsync(new[] {(byte) 0}, cancellationToken);
            }
            else
            {
                var bufferTuple = CreateWriteVarInt32((uint) map.Count);
                await Trans.WriteAsync(bufferTuple.Item1, 0, bufferTuple.Item2, cancellationToken);
                await
                    Trans.WriteAsync(
                        new[] {(byte) ((GetCompactType(map.KeyType) << 4) | GetCompactType(map.ValueType))},
                        cancellationToken);
            }
        }
Esempio n. 4
0
 public override async Task WriteMapBeginAsync(TMap map, CancellationToken cancellationToken)
 {
     await _wrappedProtocol.WriteMapBeginAsync(map, cancellationToken);
 }
Esempio n. 5
0
        public override async Task<TMap> ReadMapBeginAsync(CancellationToken cancellationToken)
        {
            if (cancellationToken.IsCancellationRequested)
            {
                return await Task.FromCanceled<TMap>(cancellationToken);
            }

            var map = new TMap
            {
                KeyType = (TType) await ReadByteAsync(cancellationToken),
                ValueType = (TType) await ReadByteAsync(cancellationToken),
                Count = await ReadI32Async(cancellationToken)
            };

            return map;
        }
Esempio n. 6
0
        public override async Task WriteMapBeginAsync(TMap map, CancellationToken cancellationToken)
        {
            if (cancellationToken.IsCancellationRequested)
            {
                return;
            }

            await WriteByteAsync((sbyte) map.KeyType, cancellationToken);
            await WriteByteAsync((sbyte) map.ValueType, cancellationToken);
            await WriteI32Async(map.Count, cancellationToken);
        }