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); } } }
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); }
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); }
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); }
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); }
public static AnnotationBuilder GetAnnotation(this AnnotatedElementBuilder annotatedElement, string annotationName) { return(annotatedElement.Annotations.FirstOrDefault(a => a.Name == annotationName)); }
public static bool HasAnnotation(this AnnotatedElementBuilder annotatedElement, string annotationName) { return(annotatedElement.Annotations.Any(a => a.Name == annotationName)); }
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); } } } }