Exemplo n.º 1
0
 public ClassFigure(ClassNode classnode)
     : base(classnode,type)
 {
     base.color = new Cairo.Color(0.879, 0.88, 0.90, 1.0);
 }
Exemplo n.º 2
0
        private static ClassNode GetClassNode(ClassDeclarationSyntax EachClass)
        {
            ClassNode classnode = new ClassNode();
            classnode.Name = EachClass.Identifier.ToString();

            // For each member in that class
            foreach (var member in EachClass.Members)
            {
                if (member is FieldDeclarationSyntax)
                {
                    FieldDeclarationSyntax fd = member as FieldDeclarationSyntax;

                    foreach (var field in GetFieldNodes(fd))
                    {
                        classnode.Fields.Add(field);
                    }
                }
                else if (member is MethodDeclarationSyntax)
                {
                    MethodDeclarationSyntax method = member as MethodDeclarationSyntax;
                    classnode.Methods.Add(GetMethodNode(method));
                }
                else if (member is PropertyDeclarationSyntax)
                {
                    PropertyDeclarationSyntax property = member as PropertyDeclarationSyntax;
                    classnode.Properties.Add(GetPropertyNode(property));
                }
                else if (member is EventFieldDeclarationSyntax)
                {
                    EventFieldDeclarationSyntax evnt = member as EventFieldDeclarationSyntax;
                    classnode.Events.Add(GetEventNode(evnt));
                }
            }

            if (EachClass.BaseList != null)
            {
                // We make use of the semantic model as it is required to get the full namespace
                // of the class/interface else there would be problems resolving links in the
                // class diagram.

                var res = model.GetDeclaredSymbol(EachClass);
                var baseType = res.BaseType.ToString();

                if(!baseType.Equals("object")){
                    // Only one inheritance possible.
                    classnode.Links.Add(baseType);
                }
                foreach(var item in res.Interfaces)
                {
                    //Add all interfaces that the class implements
                    classnode.Implementations.Add(item.ToString());
                }
            }
            return classnode;
        }