public bool AreSame(AsmDiagramEdge ed) { if (ed == null) { return(false); } return(ed.Node1 == Node1 && ed.Node2 == Node2); }
public bool AreCounterparts(AsmDiagramEdge ed) { if (ed == null) { return(false); } return(ed.Node2 == Node1 && ed.Node1 == Node2); }
public AsmDiagram(Assembly asm, bool withNamespaceSubGraphs = false) { if (asm == null) { throw new ArgumentNullException(nameof(asm)); } _targetedNs = asm.GetName().Name; _withNsSubgraphs = withNamespaceSubGraphs; _asmName = NfString.SafeDotNetIdentifier(asm.GetName().Name); foreach ( var asmType in asm.NfGetExportedTypes() .Where(x => !string.IsNullOrWhiteSpace(x.Namespace) && AssemblyName.ReferenceMatchesDefinition(asm.GetName(), x.Assembly.GetName()))) { var item1 = new FlattenedItem(asmType) { FlName = asmType.Name }; if (item1.IsTerminalNode || NfReflect.IsEnumType(asmType)) { continue; } foreach ( var p in asmType.NfGetProperties(NfSettings.DefaultFlags, false) .Where( x => x != null && !string.IsNullOrWhiteSpace(x.NfPropertyType(false)?.Namespace) && AssemblyName.ReferenceMatchesDefinition(x.NfPropertyType(false)?.Assembly.GetName(), asm.GetName())) ) { if (NfReflect.IsEnumType(p.PropertyType)) { continue; } var item2 = new FlattenedItem(p.PropertyType) { FlName = p.Name }; if (item2.IsTerminalNode) { continue; } var tupleOfItems = new Tuple <FlattenedItem, FlattenedItem>(item1, item2); var itemEv = new AsmDiagramEdge(tupleOfItems); if (Edges.Any(x => x.AreSame(itemEv))) { continue; } Edges.Add(itemEv); } } Edges = RemoveDuplicates(Edges); var names = Edges.SelectMany(x => x.NodeName).ToList(); var uqNames = names.Distinct().OrderBy(x => x).ToList(); _nodes = uqNames.Select(x => new AsmDiagramNode(x, GetCountOfEdgesOn(x))).ToList(); if (_withNsSubgraphs) { var uqNamespaces = _nodes.Select(x => x.NodeNamespace).Distinct().ToList(); foreach (var ns in uqNamespaces) { _nsSubGraphs.Add(new AsmDiagramSubGraph(ns, _nodes)); } } }