예제 #1
0
 /// <summary>
 /// Updates the vertex.
 /// </summary>
 /// <param name="v">The v.</param>
 public void UpdateVertex(ReferenceVertex v)
 {
     if (v == null)
     {
         throw new ArgumentNullException("v");
     }
     v.ID = m_nextId++;
 }
        void alg_WriteVertex(object sender, VertexEventArgs e)
        {
            GraphvizAlgorithm algo   = (GraphvizAlgorithm)sender;
            GraphvizVertex    vertex = new GraphvizVertex();
            ReferenceVertex   v      = e.Vertex as ReferenceVertex;

            vertex.Label = v.Name;
            if (!string.IsNullOrEmpty(v.Path))
            {
                vertex.Url = "file://" + Path.GetFullPath(v.Path);
            }
            // TODO: add .URL
            if (v.ReferenceType == ReferenceType.Project)
            {
                vertex.Shape = GraphvizVertexShape.Box;
            }
            algo.Output.Write(vertex.ToDot());
        }
        /// <summary>
        /// Adds the specified project to graph.
        /// </summary>
        /// <param name="project">The project to add.</param>
        /// <param name="graph">The target graph.</param>
        public void AddProjectToGraph(Project project, AdjacencyGraph graph)
        {
            Tracer.Indent();
            if (project.Vertex == null)
            {
                Tracer.Debug("Adding project {0} to graph ...", project.Name);
            }
            ReferenceVertex v = (project.Vertex ?? graph.AddVertex()) as ReferenceVertex;

            v.Name          = project.Name;
            v.ReferenceType = ReferenceType.Project;
            v.Path          = project.Path;
            project.Vertex  = v;
            foreach (string file in project.References)
            {
                if (Settings.Default.HideNet2Assemblies && FileRepository.IsNet20(file))
                {
                    continue;
                }
                if (Settings.Default.HideNet3Assemblies && FileRepository.IsNet30(file))
                {
                    continue;
                }
                if (Settings.Default.HideNet35Assemblies && FileRepository.IsNet35(file))
                {
                    continue;
                }
                if (FileRepository.Instance.GetByName(file) == null)
                {
                    Tracer.Debug("Adding file reference {0} to graph ...", file);
                }
                ReferenceVertex u = (FileRepository.Instance.GetByName(file) ?? graph.AddVertex()) as ReferenceVertex;
                u.Name          = FileRepository.MangleName(file);
                u.ReferenceType = ReferenceType.File;
                FileRepository.Instance.Add(file, u);
                if (!graph.ContainsEdge(v, u))
                {
                    Tracer.Debug("Adding edge {0} -> {1}", project.Name, file);
                    Console.WriteLine("Adding edge {0} -> {1}", project.Name, file);
                    graph.AddEdge(v, u);
                }
            }

            foreach (Project projRef in project.ProjectReferences)
            {
                if (projRef.Vertex == null)
                {
                    Tracer.Debug("Adding project reference {0} to graph ...", projRef.Name);
                }
                ReferenceVertex u = (projRef.Vertex ?? graph.AddVertex()) as ReferenceVertex;
                u.Name          = projRef.Name;
                u.ReferenceType = ReferenceType.Project;
                u.Path          = projRef.Path;
                //m_nameMap[u] = projRef.Name;
                //m_typeMap[u] = ReferenceType.Project;
                projRef.Vertex = u;
                if (!graph.ContainsEdge(v, u))
                {
                    Tracer.Debug("Adding edge {0} -> {1}", project.Name, projRef.Name);
                    graph.AddEdge(v, u);
                }

                AddProjectToGraph(projRef, graph);
            }
            Tracer.Dedent();
        }