Click here to Skip to main content
15,893,668 members
Articles / Desktop Programming / Windows Forms

Diagrams with Reflector and the Graph Plug-in (Part 2)

Rate me:
Please Sign up or sign in to vote.
4.27/5 (7 votes)
23 Feb 2009CPOL6 min read 35.2K   1.1K   38  
Graphing other dependencies, without Reflector now.
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Text;

using Refractor.Common;
using SDILReader;

namespace Refractor.Plugins.ILDiagrams
{
    public class AllAssembliesGb : BaseILGraphBuilder
    {
        public override void Translate()
        {
            FirstPass();
            SecondPass();
        }

        private void FirstPass()
        {
            RootItem root = _activeItem as RootItem;
            foreach (BaseItem item in root.Files)
            {
                if (item as AssemblyItem == null) continue;

                AssemblyItem assemblyItem = (AssemblyItem)item;

                this.AddNode(assemblyItem.PureName(), assemblyItem.PureName(),
                    _sharedOptions.AssemblyColor, assemblyItem);
            }
        }
                
        private void SecondPass()
        {
            RootItem root = _activeItem as RootItem;
            foreach (BaseItem item in root.Files)
            {
                if (item as AssemblyItem == null) continue;

                AssemblyItem assemblyItem = (AssemblyItem)item;
                string idFrom = assemblyItem.PureName();

                // We can use referenced assemblies as a shortcut, rather than 
                // running over all the method calls in all loaded files.
                foreach (string asmName in assemblyItem.ReferencedAssemblies)
                {
                    string idTo = asmName;

                    if (this.AddedNodes.ContainsKey(idTo))
                    {
                        this.AddEdge(idFrom, idTo, EdgeStyle.NormalArrow);
                    }
                }
            }
        }
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Web Developer
United Kingdom United Kingdom
hughdoar@hotmail.com

Comments and Discussions