Ejemplo n.º 1
0
        public static async Task SkipAsync(TProtocol prot, TType type, CancellationToken cancellationToken)
        {
            if (cancellationToken.IsCancellationRequested)
            {
                await Task.FromCanceled(cancellationToken);
            }

            prot.IncrementRecursionDepth();
            try
            {
                switch (type)
                {
                case TType.Bool:
                    await prot.ReadBoolAsync(cancellationToken);

                    break;

                case TType.Byte:
                    await prot.ReadByteAsync(cancellationToken);

                    break;

                case TType.I16:
                    await prot.ReadI16Async(cancellationToken);

                    break;

                case TType.I32:
                    await prot.ReadI32Async(cancellationToken);

                    break;

                case TType.I64:
                    await prot.ReadI64Async(cancellationToken);

                    break;

                case TType.Double:
                    await prot.ReadDoubleAsync(cancellationToken);

                    break;

                case TType.String:
                    // Don't try to decode the string, just skip it.
                    await prot.ReadBinaryAsync(cancellationToken);

                    break;

                case TType.Struct:
                    await prot.ReadStructBeginAsync(cancellationToken);

                    while (true)
                    {
                        var field = await prot.ReadFieldBeginAsync(cancellationToken);

                        if (field.Type == TType.Stop)
                        {
                            break;
                        }
                        await SkipAsync(prot, field.Type, cancellationToken);

                        await prot.ReadFieldEndAsync(cancellationToken);
                    }
                    await prot.ReadStructEndAsync(cancellationToken);

                    break;

                case TType.Map:
                    var map = await prot.ReadMapBeginAsync(cancellationToken);

                    for (var i = 0; i < map.Count; i++)
                    {
                        await SkipAsync(prot, map.KeyType, cancellationToken);
                        await SkipAsync(prot, map.ValueType, cancellationToken);
                    }
                    await prot.ReadMapEndAsync(cancellationToken);

                    break;

                case TType.Set:
                    var set = await prot.ReadSetBeginAsync(cancellationToken);

                    for (var i = 0; i < set.Count; i++)
                    {
                        await SkipAsync(prot, set.ElementType, cancellationToken);
                    }
                    await prot.ReadSetEndAsync(cancellationToken);

                    break;

                case TType.List:
                    var list = await prot.ReadListBeginAsync(cancellationToken);

                    for (var i = 0; i < list.Count; i++)
                    {
                        await SkipAsync(prot, list.ElementType, cancellationToken);
                    }
                    await prot.ReadListEndAsync(cancellationToken);

                    break;
                }
            }
            finally
            {
                prot.DecrementRecursionDepth();
            }
        }
Ejemplo n.º 2
0
 public override async Task ReadSetEndAsync(CancellationToken cancellationToken)
 {
     await _wrappedProtocol.ReadSetEndAsync(cancellationToken).ConfigureAwait(false);
 }
Ejemplo n.º 3
0
 public override async Task ReadSetEndAsync(CancellationToken cancellationToken)
 {
     await _wrappedProtocol.ReadSetEndAsync(cancellationToken);
 }