Exemplo n.º 1
0
        //component dependence
        public decimal CDep(XMLItem item)
        {
            decimal CDep;

            CDep = (decimal)getAllOutgoingConnections(item.getName()) / (decimal)(rootItem.children.Count - getAllConnections().Count);
            return(CDep);
        }
Exemplo n.º 2
0
        public XMLItem _getComponentByName(String cName)
        {
            foreach (XMLItem child in children)
            {
                if (child.getName() == cName)
                {
                    return(child);
                }
                else
                {
                    XMLItem it = child._getComponentByName(cName);
                    if (it._getProperty("ItemKind") != "None")
                    {
                        return(it);  // Hehe
                    }
                }
            }
            XMLItem  none = new XMLItem();
            Property p    = new Property()
            {
                name = "ItemKind", value = "None"
            };

            none.properties.Add(p);
            return(none);
        }
Exemplo n.º 3
0
        public XMLParser(String documentPath)
        {
            String text = System.IO.File.ReadAllText(documentPath);

            this.rootItem = new XMLItem();
            MatchCollection i = reRoot.Matches(text);

            foreach (Match match in i)
            {
                GroupCollection groups = match.Groups;

                String props = groups["properties"].Value;
                _setProps(rootItem, props);

                // Create and Add Children
                String childrenText = groups["children"].Value;
                _setChildren(rootItem, childrenText);
            }

            // Set Connections
            List <String> conns = getAllConnections();

            foreach (String s in conns)
            {
                List <String> ls = Regex.Split(s, "->").ToList();
                XMLItem       a  = rootItem._getComponentByName(ls[0]);
                XMLItem       b  = rootItem._getComponentByName(ls[1]);

                a.outGoings.Add(b);
                b.inComings.Add(a);
            }
        }
Exemplo n.º 4
0
        public decimal Coupling(XMLItem item)
        {
            decimal COP;

            COP = (decimal)getAllOutgoingConnections(item.getName()) / (decimal)getAllConnections().Count;
            return(COP);
        }
Exemplo n.º 5
0
        // All outgoing connections from a container
        public int getAllOutgoingConnections(String containerName)
        {
            XMLItem container = getComponent(containerName);
            int     sum       = 0;

            // first, the container connections..
            foreach (XMLItem receiver in container.outGoings)
            {
                if (receiver.parent != container && receiver != container)
                {
                    sum++;
                }
            }

            // second, children connections
            foreach (XMLItem child in container.children)
            {
                foreach (XMLItem receiver in child.outGoings)
                {
                    if (receiver.parent != container && receiver != container)
                    {
                        sum++;
                    }
                }
            }
            return(sum);
        }
Exemplo n.º 6
0
        public int getItemChildrenConnections(XMLItem it)
        {
            int sum = 0;

            foreach (XMLItem item in it.children)
            {
                sum += item.inComings.Count + item.outGoings.Count;
            }
            return(sum);
        }
Exemplo n.º 7
0
        public int getConsTo(String containerName)
        {
            XMLItem container = getComponent(containerName);
            int     sum       = 0;

            foreach (XMLItem sen in container.inComings)
            {
                if (sen.parent == rootItem)
                {
                    sum++;
                }
            }
            return(sum);
        }
Exemplo n.º 8
0
        public int getContainersConnectedTo(String containerName)
        {
            XMLItem container = getComponent(containerName);
            int     sum       = 0;

            foreach (XMLItem rec in container.outGoings)
            {
                if (rec.parent == rootItem)
                {
                    sum++;
                }
            }
            return(sum);
        }
Exemplo n.º 9
0
        public void _setProps(XMLItem item, String props)
        {
            MatchCollection i = reProps.Matches(props);

            foreach (Match match in i)
            {
                GroupCollection groups = match.Groups;
                Property        p      = new Property
                {
                    name  = groups["name"].Value,
                    value = groups["value"].Value
                };
                item.properties.Add(p);
            }
        }
Exemplo n.º 10
0
        // Inner Connections
        public int getConnectionsInsideContainer(String containerName)
        {
            XMLItem container = getComponent(containerName);
            int     sum       = 0;

            foreach (XMLItem child in container.children)
            {
                foreach (XMLItem sender in child.inComings)
                {
                    if (sender.parent == container)
                    {
                        sum++;
                    }
                }
            }
            return(sum);
        }
Exemplo n.º 11
0
        public void _setChildren(XMLItem root, String childrenText)
        {
            MatchCollection i = reItemsNChildren.Matches(childrenText);

            foreach (Match itemAndChild in i)
            {
                GroupCollection groups = itemAndChild.Groups;

                String  props = groups["properties"].Value;
                XMLItem child = new XMLItem();
                _setProps(child, props);
                child.parent = root;
                root.children.Add(child);

                String childsChildren = groups["children"].Value;
                if (!String.IsNullOrEmpty(childsChildren))
                {
                    _setChildren(child, childsChildren);
                }
            }
        }
Exemplo n.º 12
0
        public double Cohesion(XMLItem item)
        {
            double MC, COH;

            if (item._getProperty("ItemKind") == "DiagramShape")
            {
                return(1);
            }
            else
            {
                MC  = getSubComponents(item.getName()) * (getSubComponents(item.getName()) - 1) * 0.5;
                COH = getConnectionsInsideContainer(item.getName()) / MC;
                if (COH == 0 || MC == 0)
                {
                    return(1);
                }
                else
                {
                    return(COH);
                }
            }
        }
Exemplo n.º 13
0
        // sub components
        public int getSubComponents(String containerName)
        {
            XMLItem container = getComponent(containerName);

            return(container.children.Count);
        }