Example #1
0
        internal static void CopyAnnotations(AnnotatedElementBuilder from, AnnotatedElementBuilder to)
        {
            if (from == null)
            {
                return;
            }
            if (to == null)
            {
                return;
            }
            SoalFactory f = new Symbols.SoalFactory(to.MModel);

            foreach (var annot in from.Annotations)
            {
                AnnotationBuilder toAnnot = f.Annotation();
                toAnnot.Name = annot.Name;
                to.Annotations.Add(toAnnot);
                foreach (var annotProp in annot.Properties)
                {
                    AnnotationPropertyBuilder toAnnotProp = f.AnnotationProperty();
                    toAnnotProp.Name  = annotProp.Name;
                    toAnnotProp.Value = annotProp.Value;
                    toAnnot.Properties.Add(toAnnotProp);
                }
            }
        }
Example #2
0
        public static object GetAnnotationPropertyValue(this AnnotatedElementBuilder annotatedElement, string annotationName, string propertyName)
        {
            var annot = annotatedElement.Annotations.FirstOrDefault(a => a.Name == annotationName);

            if (annot != null)
            {
                return(annot.GetPropertyValue(propertyName));
            }
            return(null);
        }
Example #3
0
        public static bool HasAnnotationProperty(this AnnotatedElementBuilder annotatedElement, string annotationName, string propertyName)
        {
            var annot = annotatedElement.Annotations.FirstOrDefault(a => a.Name == annotationName);

            if (annot != null)
            {
                return(annot.HasProperty(propertyName));
            }
            return(false);
        }
Example #4
0
        public static void SetAnnotationPropertyValue(this AnnotatedElementBuilder annotatedElement, string annotationName, string propertyName, object value)
        {
            var annot = annotatedElement.Annotations.FirstOrDefault(a => a.Name == annotationName);

            if (annot == null)
            {
                SoalFactory f = new SoalFactory(annotatedElement.MModel);
                annot      = f.Annotation();
                annot.Name = annotationName;
                annotatedElement.Annotations.Add(annot);
            }
            annot.SetPropertyValue(propertyName, value);
        }
Example #5
0
        public static AnnotationBuilder AddAnnotation(this AnnotatedElementBuilder annotatedElement, string annotationName)
        {
            AnnotationBuilder result = annotatedElement.GetAnnotation(annotationName);

            if (result == null)
            {
                SoalFactory f = new Symbols.SoalFactory(annotatedElement.MModel);
                result      = f.Annotation();
                result.Name = annotationName;
                annotatedElement.Annotations.Add(result);
            }
            return(result);
        }
Example #6
0
 public static AnnotationBuilder GetAnnotation(this AnnotatedElementBuilder annotatedElement, string annotationName)
 {
     return(annotatedElement.Annotations.FirstOrDefault(a => a.Name == annotationName));
 }
Example #7
0
 public static bool HasAnnotation(this AnnotatedElementBuilder annotatedElement, string annotationName)
 {
     return(annotatedElement.Annotations.Any(a => a.Name == annotationName));
 }
Example #8
0
 internal static void CopyAnnotationProperty(string annotationName, string propertyName, AnnotatedElementBuilder from, string targetAnnotationName, string targetPropertyName, AnnotatedElementBuilder to)
 {
     foreach (var annot in from.Annotations)
     {
         if (annot.Name == annotationName)
         {
             AnnotationPropertyBuilder annotProp = annot.Properties.FirstOrDefault(prop => prop.Name == propertyName);
             if (annotProp != null)
             {
                 to.SetAnnotationPropertyValue(targetAnnotationName, targetPropertyName, annotProp.Value);
             }
         }
     }
 }