Ejemplo n.º 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);
            }
        }
    }
Ejemplo n.º 2
0
 public void AddInstance(FAMIX.AnnotationInstance one)
 {
     instances.Add(one);
 }