public static void Write(BinaryAnnotation annotation, ThriftProtocol oprot) { oprot.IncrementRecursionDepth(); try { var struc = new TStruct(/*"BinaryAnnotation"*/); oprot.WriteStructBegin(struc); var field = new TField(); if (annotation.Key != null) { // field.Name = "key"; field.Type = TType.String; field.ID = 1; oprot.WriteFieldBegin(field); oprot.WriteString(annotation.Key); oprot.WriteFieldEnd(); } // if (annotation.Value != null) { // field.Name = "value"; field.Type = TType.String; field.ID = 2; oprot.WriteFieldBegin(field); switch (annotation.AnnotationType) { case AnnotationType.BOOL: oprot.WriteI32(1); oprot.WriteByte((sbyte)(annotation.ValAsBool ? 1 : 0)); break; case AnnotationType.I16: oprot.WriteI32(2); oprot.WriteI16(annotation.ValAsI16); break; case AnnotationType.I32: oprot.WriteI32(4); oprot.WriteI32(annotation.ValAsI32); break; case AnnotationType.I64: oprot.WriteI32(8); oprot.WriteI64(annotation.ValAsI64); break; case AnnotationType.DOUBLE: oprot.WriteI32(8); oprot.WriteDouble(annotation.ValAsDouble); break; case AnnotationType.BYTES: oprot.WriteBinary(annotation.ValAsBArray, 0, annotation.ValAsBArray.Length); break; case AnnotationType.STRING: oprot.WriteString(annotation.ValAsString); break; } // oprot.WriteBinary(annotation.Value); oprot.WriteFieldEnd(); } // if (annotation.AnnotationType != null) { // field.Name = "annotation_type"; field.Type = TType.I32; field.ID = 3; oprot.WriteFieldBegin(field); oprot.WriteI32((int)annotation.AnnotationType); oprot.WriteFieldEnd(); } if (annotation.Host != null) { // field.Name = "host"; field.Type = TType.Struct; field.ID = 4; oprot.WriteFieldBegin(field); EndpointSerializer.Write(annotation.Host, oprot); //annotation.Host.Write(oprot); oprot.WriteFieldEnd(); } oprot.WriteFieldStop(); oprot.WriteStructEnd(); } finally { oprot.DecrementRecursionDepth(); } }