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)); }
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(); } }
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); }
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); }