public static IMutableAnnotatable HasExtendedProperty(IMutableAnnotatable annotatable, String key, String value)
        {
            var annotation       = annotatable.FindAnnotation(nameof(ExtendedProperty)) ?? new Annotation(nameof(ExtendedProperty), "{}");
            var annotationValues = JsonSerializer.Deserialize <Dictionary <String, String> >(annotation.Value as String);

            annotationValues.Add(key, value);

            annotatable.SetAnnotation(nameof(ExtendedProperty), JsonSerializer.Serialize(annotationValues));
            return(annotatable);
        }
        internal static ExtendedProperty[] GetExtendedProperties(this IMutableAnnotatable operation)
        {
            var annotation = operation.FindAnnotation(nameof(ExtendedProperty));

            if (annotation == null)
            {
                return(new ExtendedProperty[0]);
            }
            var annotationValues = JsonSerializer.Deserialize <Dictionary <String, String> >(annotation.Value as String);

            return(annotationValues.Select(x => new ExtendedProperty(x.Key, x.Value)).ToArray());
        }
 /// <summary>
 ///     Gets the existing annotation with a given key, or adds a new annotation if one does not exist.
 /// </summary>
 /// <param name="annotatable"> The object to find or add the annotation to. </param>
 /// <param name="annotationName"> The key of the annotation to be found or added. </param>
 /// <param name="value"> The value to be stored in the annotation if a new one is created. </param>
 /// <returns> The found or added annotation. </returns>
 public static Annotation GetOrAddAnnotation(
     [NotNull] this IMutableAnnotatable annotatable, [NotNull] string annotationName, [NotNull] string value)
 => annotatable.FindAnnotation(annotationName) ?? annotatable.AddAnnotation(annotationName, value);