public JsonBinaryAnnotation(BinaryAnnotation ba) { key = ba.key; annotationType = ba.type.ToString(); endpoint = new JsonEndpoint(ba.endpoint); switch (ba.type) { case AnnotationType.BOOL: value = BitConverter.ToBoolean(ba.value, 0); break; case AnnotationType.BYTES: value = Convert.ToBase64String(ba.value); break; case AnnotationType.I16: value = BitConverter.ToInt16(ba.value, 0); break; case AnnotationType.I32: value = BitConverter.ToInt32(ba.value, 0); break; case AnnotationType.I64: value = BitConverter.ToInt64(ba.value, 0); break; case AnnotationType.DOUBLE: value = BitConverter.ToDouble(ba.value, 0); break; case AnnotationType.STRING: value = Encoding.UTF8.GetString(ba.value); break; default: throw new Exception(string.Format("Unsupported annotation type: {0}", ba)); } }
public JsonAnnotation(Annotation annotation) { this.timestamp = annotation.timestamp; this.value = annotation.value; this.endpoint = new JsonEndpoint(annotation.endpoint); }