Пример #1
0
        public static TApplicationException Read(ThriftProtocol iprot)
        {
            TField field;

            string        message = null;
            ExceptionType type    = ExceptionType.Unknown;

            iprot.ReadStructBegin();
            while (true)
            {
                field = iprot.ReadFieldBegin();
                if (field.Type == TType.Stop)
                {
                    break;
                }

                switch (field.ID)
                {
                case 1:
                    if (field.Type == TType.String)
                    {
                        message = iprot.ReadString();
                    }
                    else
                    {
                        iprot.Skip(field.Type);
                    }
                    break;

                case 2:
                    if (field.Type == TType.I32)
                    {
                        type = (ExceptionType)iprot.ReadI32();
                    }
                    else
                    {
                        iprot.Skip(field.Type);
                    }
                    break;

                default:
                    iprot.Skip(field.Type);
                    break;
                }

                iprot.ReadFieldEnd();
            }

            iprot.ReadStructEnd();

            return(new TApplicationException(type, message));
        }
Пример #2
0
            public void Read(ThriftProtocol iprot)
            {
                iprot.IncrementRecursionDepth();
                try
                {
                    TField field;
                    iprot.ReadStructBegin();
                    while (true)
                    {
                        field = iprot.ReadFieldBegin();
                        if (field.Type == TType.Stop)
                        {
                            break;
                        }
                        switch (field.ID)
                        {
                        case 1:
                            if (field.Type == TType.List)
                            {
                                {
                                    Messages = new List <LogEntry>();
                                    TList list = iprot.ReadListBegin();
                                    for (int i = 0; i < list.Count; ++i)
                                    {
                                        var entry = LogEntrySerializer.Read(iprot);
                                        Messages.Add(entry);
                                    }
                                    iprot.ReadListEnd();
                                }
                            }
                            else
                            {
                                iprot.Skip(field.Type);
                            }
                            break;

                        default:
                            iprot.Skip(field.Type);
                            break;
                        }
                        iprot.ReadFieldEnd();
                    }
                    iprot.ReadStructEnd();
                }
                finally
                {
                    iprot.DecrementRecursionDepth();
                }
            }
Пример #3
0
            public void Read(ThriftProtocol iprot)
            {
                iprot.IncrementRecursionDepth();
                try
                {
                    TField field;
                    iprot.ReadStructBegin();
                    while (true)
                    {
                        field = iprot.ReadFieldBegin();
                        if (field.Type == TType.Stop)
                        {
                            break;
                        }
                        switch (field.ID)
                        {
                        case 0:
                            if (field.Type == TType.I32)
                            {
                                Success = (ResultCode)iprot.ReadI32();
                            }
                            else
                            {
                                iprot.Skip(field.Type);
                            }
                            break;

                        default:
                            iprot.Skip(field.Type);
                            break;
                        }
                        iprot.ReadFieldEnd();
                    }
                    iprot.ReadStructEnd();
                }
                finally
                {
                    iprot.DecrementRecursionDepth();
                }
            }
Пример #4
0
        public static Span Read(ThriftProtocol iprot)
        {
            iprot.IncrementRecursionDepth();
            var span = new Span();

            try
            {
                TField field;
                iprot.ReadStructBegin();
                while (true)
                {
                    field = iprot.ReadFieldBegin();
                    if (field.Type == TType.Stop)
                    {
                        break;
                    }
                    switch (field.ID)
                    {
                    case 1:
                        if (field.Type == TType.I64)
                        {
                            span.TraceId = iprot.ReadI64();
                        }
                        else
                        {
                            iprot.Skip(field.Type);
                        }
                        break;

                    case 3:
                        if (field.Type == TType.String)
                        {
                            span.Name = iprot.ReadString();
                        }
                        else
                        {
                            iprot.Skip(field.Type);
                        }
                        break;

                    case 4:
                        if (field.Type == TType.I64)
                        {
                            span.Id = iprot.ReadI64();
                        }
                        else
                        {
                            iprot.Skip(field.Type);
                        }
                        break;

                    case 5:
                        if (field.Type == TType.I64)
                        {
                            span.ParentId = iprot.ReadI64();
                        }
                        else
                        {
                            iprot.Skip(field.Type);
                        }
                        break;

                    case 6:
                        if (field.Type == TType.List)
                        {
                            {
                                span.Annotations = new List <Annotation>();
                                var _list0 = iprot.ReadListBegin();
                                for (int _i1 = 0; _i1 < _list0.Count; ++_i1)
                                {
                                    var annotation = AnnotationSerializer.Read(iprot);
                                    span.Annotations.Add(annotation);
                                }
                                iprot.ReadListEnd();
                            }
                        }
                        else
                        {
                            iprot.Skip(field.Type);
                        }
                        break;

                    case 8:
                        if (field.Type == TType.List)
                        {
                            {
                                span.BinaryAnnotations = new List <BinaryAnnotation>();
                                var _list3 = iprot.ReadListBegin();
                                for (int _i4 = 0; _i4 < _list3.Count; ++_i4)
                                {
//										BinaryAnnotation _elem5;
//										_elem5 = new BinaryAnnotation();
//										_elem5.Read(iprot);
//										Binary_annotations.Add(_elem5);
                                    var annotation = BinaryAnnotationSerializer.Read(iprot);
                                    span.BinaryAnnotations.Add(annotation);
                                }
                                iprot.ReadListEnd();
                            }
                        }
                        else
                        {
                            iprot.Skip(field.Type);
                        }
                        break;

                    case 9:
                        if (field.Type == TType.Bool)
                        {
                            span.IsDebug = iprot.ReadBool();
                        }
                        else
                        {
                            iprot.Skip(field.Type);
                        }
                        break;

                    case 10:
                        if (field.Type == TType.I64)
                        {
                            span.Timestamp = DateTimeOffsetExtensions.FromLong(iprot.ReadI64());
                        }
                        else
                        {
                            iprot.Skip(field.Type);
                        }
                        break;

                    case 11:
                        if (field.Type == TType.I64)
                        {
                            span.DurationInMicroseconds = iprot.ReadI64();
                        }
                        else
                        {
                            iprot.Skip(field.Type);
                        }
                        break;

                    default:
                        iprot.Skip(field.Type);
                        break;
                    }
                    iprot.ReadFieldEnd();
                }
                iprot.ReadStructEnd();
            }
            finally
            {
                iprot.DecrementRecursionDepth();
            }
            return(span);
        }
Пример #5
0
        public static Endpoint Read(ThriftProtocol iprot)
        {
            var endpoint = new Endpoint();

            iprot.IncrementRecursionDepth();
            try
            {
                iprot.ReadStructBegin();
                while (true)
                {
                    var field = iprot.ReadFieldBegin();
                    if (field.Type == TType.Stop)
                    {
                        break;
                    }
                    switch (field.ID)
                    {
                    case 1:
                        if (field.Type == TType.I32)
                        {
                            endpoint.IPAddress = new IPAddress((long)iprot.ReadI32());
                        }
                        else
                        {
                            iprot.Skip(field.Type);
                        }
                        break;

                    case 2:
                        if (field.Type == TType.I16)
                        {
                            endpoint.Port = (ushort)iprot.ReadI16();
                        }
                        else
                        {
                            iprot.Skip(field.Type);
                        }
                        break;

                    case 3:
                        if (field.Type == TType.String)
                        {
                            endpoint.ServiceName = iprot.ReadString();
                        }
                        else
                        {
                            iprot.Skip(field.Type);
                        }
                        break;

                    default:
                        iprot.Skip(field.Type);
                        break;
                    }
                    iprot.ReadFieldEnd();
                }
                iprot.ReadStructEnd();
            }
            finally
            {
                iprot.DecrementRecursionDepth();
            }

            return(endpoint);
        }
Пример #6
0
        public static BinaryAnnotation Read(ThriftProtocol iprot)
        {
            iprot.IncrementRecursionDepth();
            var annotation = new BinaryAnnotation();

            byte[] value = null;
            try
            {
                iprot.ReadStructBegin();
                while (true)
                {
                    var field = iprot.ReadFieldBegin();
                    if (field.Type == TType.Stop)
                    {
                        break;
                    }
                    switch (field.ID)
                    {
                    case 1:
                        if (field.Type == TType.String)
                        {
                            annotation.Key = iprot.ReadString();
                        }
                        else
                        {
                            iprot.Skip(field.Type);
                        }
                        break;

                    case 2:
                        if (field.Type == TType.String)
                        {
                            value = iprot.ReadBinary();
                        }
                        else
                        {
                            iprot.Skip(field.Type);
                        }
                        break;

                    case 3:
                        if (field.Type == TType.I32)
                        {
                            annotation.AnnotationType = (AnnotationType)iprot.ReadI32();
                        }
                        else
                        {
                            iprot.Skip(field.Type);
                        }
                        break;

                    case 4:
                        if (field.Type == TType.Struct)
                        {
                            // Host = new Endpoint();
                            // Host.Read(iprot);
                            annotation.Host = EndpointSerializer.Read(iprot);
                        }
                        else
                        {
                            iprot.Skip(field.Type);
                        }
                        break;

                    default:
                        iprot.Skip(field.Type);
                        break;
                    }
                    iprot.ReadFieldEnd();
                }
                iprot.ReadStructEnd();
            }
            finally
            {
                iprot.DecrementRecursionDepth();
            }
            // annotation.InitWith(value);

            if (value != null)
            {
                switch (annotation.AnnotationType)
                {
                case AnnotationType.BOOL:
                    annotation.ValAsBool = value.Length == 1 && value[0] == 1;
                    break;

                case AnnotationType.I16:
                    Array.Reverse(value);
                    annotation.ValAsI16 = BitConverter.ToInt16(value, 0);
                    break;

                case AnnotationType.I32:
                    Array.Reverse(value);
                    annotation.ValAsI32 = BitConverter.ToInt32(value, 0);
                    break;

                case AnnotationType.I64:
                    Array.Reverse(value);
                    annotation.ValAsI64 = BitConverter.ToInt64(value, 0);
                    break;

                case AnnotationType.DOUBLE:
                    Array.Reverse(value);
                    annotation.ValAsDouble = BitConverter.ToDouble(value, 0);
                    break;

                case AnnotationType.BYTES:
                    Array.Reverse(value);
                    annotation.ValAsBArray = value;
                    break;

                case AnnotationType.STRING:
                    annotation.ValAsString = Encoding.UTF8.GetString(value, 0, value.Length);
                    break;
                }
            }

            return(annotation);
        }
Пример #7
0
        public static Annotation Read(ThriftProtocol iprot)
        {
            iprot.IncrementRecursionDepth();
            var annotation = new Annotation();

            try
            {
                iprot.ReadStructBegin();
                while (true)
                {
                    var field = iprot.ReadFieldBegin();
                    if (field.Type == TType.Stop)
                    {
                        break;
                    }
                    switch (field.ID)
                    {
                    case 1:
                        if (field.Type == TType.I64)
                        {
                            annotation.Timestamp = DateTimeOffsetExtensions.FromLong(iprot.ReadI64());
                        }
                        else
                        {
                            iprot.Skip(field.Type);
                        }
                        break;

                    case 2:
                        if (field.Type == TType.String)
                        {
                            annotation.Value = iprot.ReadString();
                        }
                        else
                        {
                            iprot.Skip(field.Type);
                        }
                        break;

                    case 3:
                        if (field.Type == TType.Struct)
                        {
//								Host = new Endpoint();
//								Host.Read(iprot);
                            annotation.Host = EndpointSerializer.Read(iprot);
                        }
                        else
                        {
                            iprot.Skip(field.Type);
                        }
                        break;

                    default:
                        iprot.Skip(field.Type);
                        break;
                    }
                    iprot.ReadFieldEnd();
                }
                iprot.ReadStructEnd();
            }
            finally
            {
                iprot.DecrementRecursionDepth();
            }
            return(annotation);
        }