Beispiel #1
0
    //TODO add AnnotationInstanceAttribute link to AnnotationAttribute is not implemented
    //because in C# there are AnnotationAttributes that are initilized via constructors
    private void AddAnnotations(INamedTypeSymbol typeSymbol, FAMIX.NamedEntity type)
    {
        var attributes = typeSymbol.GetAttributes();

        foreach (var attr in attributes)
        {
            try
            {
                FAMIX.AnnotationInstance annotationInstance = importer.New <FAMIX.AnnotationInstance>();

                FAMIX.AnnotationType annonType = (FAMIX.AnnotationType)importer.EnsureType(attr.AttributeClass, typeof(FAMIX.AnnotationType));
                annotationInstance.annotatedEntity = type;
                annotationInstance.annotationType  = annonType;

                foreach (var constrArgument in attr.ConstructorArguments)
                {
                    AnnotationInstanceAttribute annotationInstanceAttribute = importer.New <FAMIX.AnnotationInstanceAttribute>();
                    annotationInstanceAttribute.value = constrArgument.Value.ToString();
                    annotationInstance.AddAttribute(annotationInstanceAttribute);
                }
                foreach (var namedArgument in attr.NamedArguments)
                {
                    AnnotationInstanceAttribute annotationInstanceAttribute = importer.New <FAMIX.AnnotationInstanceAttribute>();
                    annotationInstanceAttribute.value = namedArgument.Value.ToString();
                    annotationInstance.AddAttribute(annotationInstanceAttribute);
                }
            }
            catch (InvalidCastException c)
            {
                Console.WriteLine(c.Message);
            }
        }
    }
Beispiel #2
0
        public FAMIX.Attribute EnsureAnnotationTypeAttribute(FAMIX.AnnotationType annotationType, String attributeName)
        {
            var attributes = annotationType.Attributes.FindAll(a => a.name == attributeName);

            if (attributes.Count() > 0)
            {
                return(attributes[0]);
            }

            FAMIX.Attribute attr = this.CreateNewEntity <FAMIX.Attribute>(typeof(FAMIX.Attribute).FullName);
            attr.name = attributeName;
            annotationType.AddAttribute(attr);
            return(attr);
        }
Beispiel #3
0
 public void AddDefinedAnnotationType(FAMIX.AnnotationType one)
 {
     definedAnnotationTypes.Add(one);
 }