protected virtual void CopyAnnotations([NotNull] IEnumerable <IAnnotation> annotations, [NotNull] IMutableAnnotatable annotatable)
 {
     foreach (var annotation in annotations)
     {
         annotatable.AddAnnotation(annotation.Name, annotation.Value);
     }
 }
Beispiel #2
0
 internal static void AddAnnotations([NotNull] IMutableAnnotatable annotatable, [NotNull] IEnumerable <IAnnotation> annotations)
 {
     foreach (var annotation in annotations)
     {
         annotatable.AddAnnotation(annotation.Name, annotation.Value);
     }
 }
 /// <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);