Esempio n. 1
0
        private void AddLinksFromClasses(TypeItem fromTypeItem, string toTypeId)
        {
            if (fromTypeItem.Implements == null)
            {
                return;
            }

            string fromTypeId = fromTypeItem.GetShortID();

            foreach (string id in fromTypeItem.Implements)
            {
                // We're looking for hits on one specific method.
                if (id != toTypeId)
                {
                    continue;
                }

                BaseItem baseItem = _projectBrowser.Lookup(id);

                // If the interface is not present in our project, then forget about it.
                if (baseItem == null)
                {
                    continue;
                }

                // Only add types once.
                if (_addedNodes.ContainsKey(fromTypeId))
                {
                    continue;
                }

                //AddNode(fromTypeId, GetNameForItem(fromTypeItem), _sharedOptions.TypeColor, fromTypeItem);
                Color color = GetColorForNode(fromTypeItem, ChangeBrightnessColor(_sharedOptions.TypeColor, 1));

                AddNode(fromTypeId, GetNameForItem(fromTypeItem), color, fromTypeItem);
                AddEdge(fromTypeId, toTypeId, EdgeStyle.NormalArrow, Color.DarkSeaGreen); //todo
            }
        }
Esempio n. 2
0
        private void AddLinkFromInherited(TypeItem fromTypeItem, string toTypeId)
        {
            string id = fromTypeItem.InheritsFrom;

            // We're looking for hits on one specific method.
            // Everything that inherits from the toType.
            if (id != toTypeId)
            {
                return;
            }

            string fromTypeId = fromTypeItem.GetShortID();

            BaseItem baseItem = _projectBrowser.Lookup(id);

            // If the interface is not present in our project, then forget about it.
            if (baseItem == null)
            {
                return;
            }

            // Only add nodes once.
            //if (_addedNodes.ContainsKey(fromTypeId))
            //{
            //    object baby = _addedNodes[fromTypeId];
            //    UpdateNodeColor(baby, _sharedOptions.TypeColor);
            //}
            //else
            //{
            Color color = GetColorForNode(baseItem, ChangeBrightnessColor(_sharedOptions.TypeColor, 1));

            AddNode(fromTypeId, GetNameForItem(baseItem), color, baseItem);
            //}

            AddEdge(fromTypeId, toTypeId, EdgeStyle.NormalArrow);
        }
Esempio n. 3
0
        private void AddLinksFromMethods(TypeItem fromTypeItem, string toTypeId)
        {
            foreach (MethodItem methodItem in fromTypeItem.Methods)
            {
                string fromTypeId = fromTypeItem.GetShortID();

                MethodBodyReader mr = new MethodBodyReader(methodItem.MethodInfo);
                if (mr == null)
                {
                    continue;
                }

                // Abstract..external, etc
                if (mr.instructions == null)
                {
                    continue;
                }

                foreach (ILInstruction instruction in mr.instructions)
                {
                    string id = string.Empty;

                    if (instruction.Code.OperandType != OperandType.InlineMethod)
                    {
                        continue;
                    }

                    // TODO dup code
                    if (instruction.Operand is MethodInfo)
                    {
                        id = (instruction.Operand as MethodInfo).DeclaringType.ToString();
                    }
                    else if (instruction.Operand is ConstructorInfo)
                    {
                        id = (instruction.Operand as ConstructorInfo).DeclaringType.ToString();
                    }
                    else if (instruction.Operand == null)
                    {
                        _logView.LogStr("Class Butterfly failed to recognise call instruction due to generics.(in)");
                    }
                    else
                    {
                        _logView.LogStr("Class Butterfly failed to recognise call instruction (in) :" + instruction.Operand.GetType().ToString());
                    }

                    // We're looking for hits on one specific method.
                    if (id != toTypeId)
                    {
                        continue;
                    }

                    // Only add nodes once.
                    //if (_addedNodes.ContainsKey(fromTypeId)) continue;

                    //AddNode(fromTypeId, GetNameForItem(fromTypeItem), ChangeBrightnessColor(_sharedOptions.TypeColor,0.8), fromTypeItem);
                    Color color = GetColorForNode(fromTypeItem, ChangeBrightnessColor(_sharedOptions.TypeColor, 1));

                    AddNode(fromTypeId, GetNameForItem(fromTypeItem), color, fromTypeItem);
                    AddEdge(fromTypeId, toTypeId, EdgeStyle.NormalArrow);
                }
            }
        }
Esempio n. 4
0
        private void AddLinkFromInherited(TypeItem fromTypeItem, string toTypeId)
        {
            string id = fromTypeItem.InheritsFrom;

            // We're looking for hits on one specific method.
            // Everything that inherits from the toType.
            if (id != toTypeId) return;

            string fromTypeId = fromTypeItem.GetShortID();

            BaseItem baseItem = _projectBrowser.Lookup(id);

            // If the interface is not present in our project, then forget about it.
            if (baseItem == null) return;

            // Only add nodes once.
            //if (_addedNodes.ContainsKey(fromTypeId))
            //{
            //    object baby = _addedNodes[fromTypeId];
            //    UpdateNodeColor(baby, _sharedOptions.TypeColor);
            //}
            //else
            //{
            Color color = GetColorForNode(baseItem, ChangeBrightnessColor(_sharedOptions.TypeColor, 1));

            AddNode(fromTypeId, GetNameForItem(baseItem), color, baseItem);
            //}

            AddEdge(fromTypeId, toTypeId, EdgeStyle.NormalArrow);
        }
Esempio n. 5
0
        private void AddLinksFromMethods(TypeItem fromTypeItem, string toTypeId)
        {
            foreach (MethodItem methodItem in fromTypeItem.Methods)
            {
                string fromTypeId = fromTypeItem.GetShortID();

                MethodBodyReader mr = new MethodBodyReader(methodItem.MethodInfo);
                if (mr == null) continue;

                // Abstract..external, etc
                if (mr.instructions == null) continue;

                foreach (ILInstruction instruction in mr.instructions)
                {
                    string id = string.Empty;

                    if (instruction.Code.OperandType != OperandType.InlineMethod) continue;

                    // TODO dup code
                    if (instruction.Operand is MethodInfo)
                    {
                        id = (instruction.Operand as MethodInfo).DeclaringType.ToString();
                    }
                    else if (instruction.Operand is ConstructorInfo)
                    {
                        id = (instruction.Operand as ConstructorInfo).DeclaringType.ToString();
                    }
                    else if (instruction.Operand == null)
                    {
                        _logView.LogStr("Class Butterfly failed to recognise call instruction due to generics.(in)");
                    }
                    else
                    {
                        _logView.LogStr("Class Butterfly failed to recognise call instruction (in) :" + instruction.Operand.GetType().ToString());
                    }

                    // We're looking for hits on one specific method.
                    if (id != toTypeId) continue;

                    // Only add nodes once.
                    //if (_addedNodes.ContainsKey(fromTypeId)) continue;

                    //AddNode(fromTypeId, GetNameForItem(fromTypeItem), ChangeBrightnessColor(_sharedOptions.TypeColor,0.8), fromTypeItem);
                    Color color = GetColorForNode(fromTypeItem, ChangeBrightnessColor(_sharedOptions.TypeColor, 1));

                    AddNode(fromTypeId, GetNameForItem(fromTypeItem), color, fromTypeItem);
                    AddEdge(fromTypeId, toTypeId, EdgeStyle.NormalArrow);
                }
            }
        }
Esempio n. 6
0
        private void AddLinksFromClasses(TypeItem fromTypeItem, string toTypeId)
        {
            if (fromTypeItem.Implements == null) return;

            string fromTypeId = fromTypeItem.GetShortID();

            foreach (string id in fromTypeItem.Implements)
            {
                // We're looking for hits on one specific method.
                if (id != toTypeId) continue;

                BaseItem baseItem = _projectBrowser.Lookup(id);

                // If the interface is not present in our project, then forget about it.
                if (baseItem == null) continue;

                // Only add types once.
                if (_addedNodes.ContainsKey(fromTypeId)) continue;

                //AddNode(fromTypeId, GetNameForItem(fromTypeItem), _sharedOptions.TypeColor, fromTypeItem);
                Color color = GetColorForNode(fromTypeItem, ChangeBrightnessColor(_sharedOptions.TypeColor, 1));

                AddNode(fromTypeId, GetNameForItem(fromTypeItem), color, fromTypeItem);
                AddEdge(fromTypeId, toTypeId, EdgeStyle.NormalArrow, Color.DarkSeaGreen); //todo
            }
        }