当前位置: 首页>>代码示例>>C#>>正文


C# TType.ToString方法代码示例

本文整理汇总了C#中TType.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# TType.ToString方法的具体用法?C# TType.ToString怎么用?C# TType.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TType的用法示例。


在下文中一共展示了TType.ToString方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: SkipAsync

        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;
                    default:
                        throw new TProtocolException(TProtocolException.INVALID_DATA, "Unknown data type " + type.ToString("d"));
                }
            }
            finally
            {
                prot.DecrementRecursionDepth();
            }
        }
开发者ID:nsuke,项目名称:thrift,代码行数:82,代码来源:TProtocolUtil.cs

示例2: Skip

        public static void Skip(TProtocol prot, TType type)
        {
            prot.IncrementRecursionDepth();
            try
            {
                switch (type)
                {
                    case TType.Bool:
                        prot.ReadBool();
                        break;
                    case TType.Byte:
                        prot.ReadByte();
                        break;
                    case TType.I16:
                        prot.ReadI16();
                        break;
                    case TType.I32:
                        prot.ReadI32();
                        break;
                    case TType.I64:
                        prot.ReadI64();
                        break;
                    case TType.Double:
                        prot.ReadDouble();
                        break;
                    case TType.String:
                        // Don't try to decode the string, just skip it.
                        prot.ReadBinary();
                        break;
                    case TType.Struct:
                        prot.ReadStructBegin();
                        while (true)
                        {
                            TField field = prot.ReadFieldBegin();
                            if (field.Type == TType.Stop)
                            {
                                break;
                            }
                            Skip(prot, field.Type);
                            prot.ReadFieldEnd();
                        }
                        prot.ReadStructEnd();
                        break;
                    case TType.Map:
                        TMap map = prot.ReadMapBegin();
                        for (int i = 0; i < map.Count; i++)
                        {
                            Skip(prot, map.KeyType);
                            Skip(prot, map.ValueType);
                        }
                        prot.ReadMapEnd();
                        break;
                    case TType.Set:
                        TSet set = prot.ReadSetBegin();
                        for (int i = 0; i < set.Count; i++)
                        {
                            Skip(prot, set.ElementType);
                        }
                        prot.ReadSetEnd();
                        break;
                    case TType.List:
                        TList list = prot.ReadListBegin();
                        for (int i = 0; i < list.Count; i++)
                        {
                            Skip(prot, list.ElementType);
                        }
                        prot.ReadListEnd();
                        break;
                    default:
                        throw new TProtocolException(TProtocolException.INVALID_DATA, "Unknown data type " + type.ToString("d"));
                }

            }
            finally
            {
                prot.DecrementRecursionDepth();
            }
        }
开发者ID:nsuke,项目名称:thrift,代码行数:78,代码来源:TProtocolUtil.cs


注:本文中的TType.ToString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。