private void OnFormatEdge([NotNull] TEdge edge, [NotNull] DirectedGraphLink link)
        {
            Debug.Assert(edge != null);
            Debug.Assert(link != null);

            FormatEdge?.Invoke(edge, link);
        }
Esempio n. 2
0
        public void AddLink(DirectedGraphLink link)
        {
            var links = new List <DirectedGraphLink>(DirectedGraph.Links);

            links.Add(link);

            DirectedGraph.Links = links.ToArray();
        }
Esempio n. 3
0
        private void AddLink(DirectedGraphLink link)
        {
            EnsureLinks();

            var links     = _directedGraph.Links;
            var linkIndex = links.Length;

            Array.Resize(ref links, linkIndex + 1);
            links[linkIndex]     = link;
            _directedGraph.Links = links;
        }
Esempio n. 4
0
        private DirectedGraphLink CreateLink(DirectedGraphNode source, DirectedGraphNode target)
        {
            var link = new DirectedGraphLink
            {
                Source = source.Id,
                Target = target.Id,
            };

            AddLink(link);
            return(link);
        }
Esempio n. 5
0
        public DirectedGraphLink AddLink(string source, string target)
        {
            var link = new DirectedGraphLink()
            {
                Source = source,
                Target = target,
            };

            AddLink(link);

            return(link);
        }
        private void OnFormatEdge(TEdge edge, DirectedGraphLink link)
        {
            Contract.Requires(edge != null);
            Contract.Requires(link != null);

            var eh = this.FormatEdge;

            if (eh != null)
            {
                eh(edge, link);
            }
        }
        /// <inheritdoc />
        protected override void InternalCompute()
        {
            ICancelManager cancelManager = Services.CancelManager;

            DirectedGraph = new DirectedGraph();

            var nodes = new List <DirectedGraphNode>(VisitedGraph.VertexCount);

            foreach (TVertex vertex in VisitedGraph.Vertices)
            {
                if (cancelManager.IsCancelling)
                {
                    return;
                }

                var node = new DirectedGraphNode {
                    Id = _vertexIdentities(vertex)
                };
                OnFormatNode(vertex, node);
                nodes.Add(node);
            }

            DirectedGraph.Nodes = nodes.ToArray();

            var links = new List <DirectedGraphLink>(VisitedGraph.EdgeCount);

            foreach (TEdge edge in VisitedGraph.Edges)
            {
                if (cancelManager.IsCancelling)
                {
                    return;
                }

                var link = new DirectedGraphLink
                {
                    Label  = _edgeIdentities(edge),
                    Source = _vertexIdentities(edge.Source),
                    Target = _vertexIdentities(edge.Target)
                };
                OnFormatEdge(edge, link);
                links.Add(link);
            }

            DirectedGraph.Links = links.ToArray();

            OnFormatGraph();
        }
        protected override void InternalCompute()
        {
            var cancelManager = this.Services.CancelManager;

            this.directedGraph = new DirectedGraph();

            var nodes = new List <DirectedGraphNode>(this.VisitedGraph.VertexCount);

            foreach (var vertex in this.VisitedGraph.Vertices)
            {
                if (cancelManager.IsCancelling)
                {
                    return;
                }

                var node = new DirectedGraphNode {
                    Id = this.vertexIdentities(vertex)
                };
                this.OnFormatNode(vertex, node);
                nodes.Add(node);
            }
            this.directedGraph.Nodes = nodes.ToArray();

            var links = new List <DirectedGraphLink>(this.VisitedGraph.EdgeCount);

            foreach (var edge in this.VisitedGraph.Edges)
            {
                if (cancelManager.IsCancelling)
                {
                    return;
                }

                var link = new DirectedGraphLink
                {
                    Label  = this.edgeIdentities(edge),
                    Source = this.vertexIdentities(edge.Source),
                    Target = this.vertexIdentities(edge.Target)
                };
                this.OnFormatEdge(edge, link);
                links.Add(link);
            }
            this.directedGraph.Links = links.ToArray();

            this.OnFormatGraph();
        }
        /// <inheritdoc />
        protected override void InternalCompute()
        {
            DirectedGraph = new DirectedGraph();

            var nodes = new List <DirectedGraphNode>(VisitedGraph.VertexCount);

            foreach (TVertex vertex in VisitedGraph.Vertices)
            {
                ThrowIfCancellationRequested();

                var node = new DirectedGraphNode {
                    Id = _vertexIdentity(vertex)
                };
                OnFormatNode(vertex, node);
                nodes.Add(node);
            }

            DirectedGraph.Nodes = nodes.ToArray();

            var links = new List <DirectedGraphLink>(VisitedGraph.EdgeCount);

            foreach (TEdge edge in VisitedGraph.Edges)
            {
                ThrowIfCancellationRequested();

                var link = new DirectedGraphLink
                {
                    Label  = _edgeIdentity(edge),
                    Source = _vertexIdentity(edge.Source),
                    Target = _vertexIdentity(edge.Target)
                };
                OnFormatEdge(edge, link);
                links.Add(link);
            }

            DirectedGraph.Links = links.ToArray();

            OnFormatGraph();
        }
Esempio n. 10
0
        public void TestSave_ValidDgml()
        {
            DirectedGraphNode first = new DirectedGraphNode {
                Id = "1", Label = "first"
            };
            DirectedGraphNode second = new DirectedGraphNode {
                Id = "2", Label = "second"
            };
            DirectedGraphLink link = new DirectedGraphLink {
                Source = "1", Target = "2", Label = "connects"
            };

            DirectedGraph graph = new DirectedGraph()
            {
                Nodes = new[] { first, second },
                Links = new[] { link },
            };

            string actualDgml = graph.ToDgml();

            MatchDgml(ValidDgml, actualDgml);
        }
Esempio n. 11
0
        public void TestSave_StyledDgml()
        {
            DirectedGraphNode first = new DirectedGraphNode {
                Id = "1", Label = "first", Category1 = "category",
            };
            DirectedGraphNode second = new DirectedGraphNode {
                Id = "2", Label = "second"
            };
            DirectedGraphLink link = new DirectedGraphLink {
                Source = "1", Target = "2", Label = "connects"
            };
            DirectedGraphStyle style = DgmlHelper.CreateCategoryBackgroundStyle("category", "#FF000000");

            DirectedGraph graph = new DirectedGraph
            {
                Nodes  = new[] { first, second },
                Links  = new[] { link },
                Styles = new[] { style },
            };

            string actualDgml = graph.ToDgml();

            MatchDgml(StyledDgml, actualDgml);
        }
Esempio n. 12
0
 private void ConfigureLink(DirectedGraphLink link, PackageUpgrade upgrade)
 {
     link.Label  = upgrade.PackageDependency.VersionRange.ToString();
     link.Stroke = _palette.UpgradeActionPalette[upgrade.Action];
 }
Esempio n. 13
0
        public DirectedGraph GenerateGraph()
        {
            DirectedGraph dg = new DirectedGraph {
                Nodes = new List <DirectedGraphNode>()
            };
            var root = new DirectedGraphNode {
                Id = this.buildServer.TeamProjectCollection.Name, Label = this.buildServer.TeamProjectCollection.Name, Category1 = ProjectCollectionCategory
            };

            dg.Nodes.Add(root);
            dg.Links = new List <DirectedGraphLink>();
            var hosts = new List <DirectedGraphNode>();

            dg.Styles.Add(CreateStyle(BuildControllerCategory, BuildControllerCategoryLabel, "LightGreen"));
            dg.Styles.Add(CreateStyle(DisabledBuildControllerCategory, DisabledBuildControllerCategoryLabel, "Purple"));
            dg.Styles.Add(CreateStyle(ServiceHostCategory, ServiceHostCategoryLabel, "Yellow"));
            dg.Styles.Add(CreateStyle(BuildAgentCategory, BuildAgentCategoryLabel, "Green"));
            dg.Styles.Add(CreateStyle(DisabledBuildAgentCategory, DisabledBuildAgentCategoryLabel, "Red"));
            dg.Styles.Add(CreateStyle(ProjectCollectionCategory, ProjectCollectionCategoryLabel, "Orange"));
            dg.Styles.Add(CreateStyle(BuildAgentTagCategory, BuildAgentTagCategoryLabel, "LightBlue"));

            foreach (var controller in this.buildServer.QueryBuildControllers(true))
            {
                DirectedGraphNode hostNode;
                var host = controller.ServiceHost.Name;
                if (hosts.Any(h => h.Label == host))
                {
                    hostNode = hosts.First(h => h.Label == host);
                }
                else
                {
                    hostNode = CreateServiceHostNode(host, host);
                    hosts.Add(hostNode);
                    dg.Nodes.Add(hostNode);
                    var l = new DirectedGraphLink {
                        Source = root.Label, Target = hostNode.Label
                    };
                    dg.Links.Add(l);
                }

                var controllerNode = CreateControllerNode(controller);
                dg.Nodes.Add(controllerNode);

                var link = new DirectedGraphLink {
                    Source = hostNode.Id, Target = controllerNode.Id, Category1 = "Contains"
                };
                dg.Links.Add(link);

                foreach (var a in controller.Agents)
                {
                    var agentNode = CreateBuildAgentNode(GetBuildAgentID(a), a.Name, a.Enabled);
                    host = a.ServiceHost.Name;

                    if (hosts.Any(h => h.Label == host))
                    {
                        hostNode = hosts.First(h => h.Label == host);
                        dg.Nodes.Add(agentNode);
                        link = new DirectedGraphLink {
                            Source = controllerNode.Id, Target = agentNode.Id
                        };
                        dg.Links.Add(link);
                    }
                    else
                    {
                        hostNode = CreateServiceHostNode(host, host);
                        dg.Nodes.Add(hostNode);
                        hosts.Add(hostNode);
                        dg.Nodes.Add(agentNode);
                        link = new DirectedGraphLink {
                            Source = controllerNode.Id, Target = hostNode.Id
                        };
                        dg.Links.Add(link);
                    }

                    link = new DirectedGraphLink {
                        Source = hostNode.Id, Target = agentNode.Id, Category1 = "Contains"
                    };
                    dg.Links.Add(link);

                    foreach (var tag in a.Tags)
                    {
                        var tagNode = CreateTagNode(tag);
                        dg.Nodes.Add(tagNode);
                        link = new DirectedGraphLink {
                            Source = agentNode.Id, Target = tagNode.Id, Category1 = "Contains"
                        };
                        dg.Links.Add(link);
                    }
                }
            }

            return(dg);
        }