/// <summary> /// /// </summary> /// <param name="startingModelId"></param> /// <param name="side"></param> private void TraverseRelations(ComponentSig startingModel, GraphRelationSide side) { for (int ix = 0; ix < relations.Count; ix++) { if (processedLinks[ix]) { continue; } DependencyGraphVisitor.RelationShip relation = relations[ix]; if (startingModel.Equals(relation.Source) && side == GraphRelationSide.Source) { processedLinks.Set(ix, true); GenerateRelationInGraph(relation); if (relation.Target != null) { TraverseRelations(new ComponentSig(relation.Target), side); } } else if (relation.Target != null && startingModel.Equals(relation.Target) && side == GraphRelationSide.Target) { processedLinks.Set(ix, true); GenerateRelationInGraph(relation); TraverseRelations(new ComponentSig(relation.Source), side); } } }
/// <summary> /// Generation pour toute les relations /// </summary> public void Generate() { showMainSource = false; for (int ix = 0; ix < relations.Count; ix++) { DependencyGraphVisitor.RelationShip relation = relations[ix]; GenerateRelationInGraph(relation); } }
/// <summary> /// /// </summary> /// <param name="relation"></param> protected virtual void GenerateRelationInGraph(DependencyGraphVisitor.RelationShip relation) { bool sourceExists; string sourceId = GetId(relation.Source, null, out sourceExists); bool targetExists; string targetId = GetId(relation.Target, relation.TargetAsString, out targetExists); string source = null; string target = null; string edgeStyle = String.Empty; if (mainSource == null) { buffer.AppendLine(String.Format(@"label=""Dependencies graph for\n {0} V{1}""", relation.Source.Name, relation.Source.Version)); } if (mainSource == null && showMainSource) { source = mainSource = String.Format(@"{0}[shape=box, style=filled,fillcolor=gray, label=""{1}\nV{2}""];", sourceId, relation.Source.Name, relation.Source.Version); } else if (!sourceExists) { source = String.Format(@"{0}[URL=""Details.aspx?id={3}&version={2}"", label=""{1}\nV{2}""];", sourceId, relation.Source.Name, relation.Source.Version, relation.Source.Id); } switch (relation.Type) { case DependencyGraphVisitor.RelationShip.RelationType.Framework: if (!targetExists) { target = String.Format(@"{0}[shape=box,label="".Net\n{1}"",fontsize=12];", targetId, relation.TargetAsString); } edgeStyle = @"[arrowhead=""none""]"; break; case DependencyGraphVisitor.RelationShip.RelationType.Composants: if (!targetExists) { target = String.Format(@"{0} [URL=""Details.aspx?id={2}&version={1}"", label=""{3}\nV{1}""];", targetId, relation.Target.Version, relation.Target.Id, relation.Target.Name); } if (relation.Scope == ReferenceScope.Compilation) { edgeStyle = @"[style=""bold""]"; } break; case DependencyGraphVisitor.RelationShip.RelationType.Artifacts: if (!targetExists) { target = String.Format(@"{0}[style=dotted,label=""{1}"",fontsize=12];", targetId, relation.TargetAsString); } break; default: break; } if (source != null) { buffer.AppendLine(source); } if (target != null) { buffer.AppendLine(target); } buffer.AppendFormat("{0}->{1}{2}", sourceId, targetId, edgeStyle); buffer.AppendLine(); }