public GraphDiff MatchGraphs(PositionedGraph oldGraph, PositionedGraph newGraph) { if (oldGraph == null) { if (newGraph == null) { return(new GraphDiff()); } else { GraphDiff addAllDiff = new GraphDiff(); foreach (PositionedGraphNode newNode in newGraph.Nodes) { addAllDiff.SetAdded(newNode); } return(addAllDiff); } } else if (newGraph == null) { GraphDiff removeAllDiff = new GraphDiff(); foreach (PositionedGraphNode oldNode in oldGraph.Nodes) { removeAllDiff.SetRemoved(oldNode); } return(removeAllDiff); } // none of the graphs is null GraphDiff diff = new GraphDiff(); Dictionary <int, PositionedGraphNode> newNodeForHashCode = buildHashToNodeMap(newGraph); Dictionary <PositionedGraphNode, bool> newNodeMatched = new Dictionary <PositionedGraphNode, bool>(); foreach (PositionedGraphNode oldNode in oldGraph.Nodes) { PositionedGraphNode matchingNode = matchNode(oldNode, newNodeForHashCode); if (matchingNode != null) { diff.SetMatching(oldNode, matchingNode); newNodeMatched[matchingNode] = true; } else { diff.SetRemoved(oldNode); } } foreach (PositionedGraphNode newNode in newGraph.Nodes) { if (!newNodeMatched.ContainsKey(newNode)) { diff.SetAdded(newNode); } } return(diff); }
public ContentNode(PositionedGraphNode containingNode, ContentNode parent) { if (containingNode == null) { throw new ArgumentNullException("containingNode"); } this.containingNode = containingNode; this.parent = parent; }
private PositionedGraphNode matchNode(PositionedGraphNode oldNode, Dictionary<int, PositionedGraphNode> newNodeMap) { PositionedGraphNode newNodeFound = newNodeMap.GetValue(oldNode.ObjectNode.HashCode); if ((newNodeFound != null) && isSameAddress(oldNode, newNodeFound)) { return newNodeFound; } else { return null; } }
private PositionedGraphNode matchNode(PositionedGraphNode oldNode, Dictionary <int, PositionedGraphNode> newNodeMap) { PositionedGraphNode newNodeFound = newNodeMap.GetValue(oldNode.ObjectNode.HashCode); if ((newNodeFound != null) && isSameAddress(oldNode, newNodeFound)) { return(newNodeFound); } else { return(null); } }
/// <summary> /// Creates new PositionedNodeProperty. /// </summary> /// <param name="objectProperty">Underlying <see cref="ObjectProperty"/></param> public PositionedNodeProperty(ObjectGraphProperty objectProperty, PositionedGraphNode containingNode, bool isPropertyExpanded) { if (containingNode == null) { throw new ArgumentNullException("containingNode"); } if (objectProperty == null) { throw new ArgumentNullException("objectProperty"); } this.objectGraphProperty = objectProperty; this.containingNode = containingNode; this.IsPropertyExpanded = isPropertyExpanded; }
private PositionedGraph buildTreeGraph(ObjectGraph objectGraph, Expanded expanded) { var resultGraph = new PositionedGraph(); // create empty PosNodes foreach (ObjectGraphNode objectGraphNode in objectGraph.ReachableNodes) { TreeGraphNode posNode = createNewTreeGraphNode(objectGraphNode); resultGraph.AddNode(posNode); treeNodeFor[objectGraphNode] = posNode; posNode.InitContentFromObjectNode(expanded); } // create edges foreach (PositionedGraphNode posNode in resultGraph.Nodes) { // create edges outgoing from this posNode foreach (PositionedNodeProperty property in posNode.Properties) { //property.IsPropertyExpanded = expanded.Expressions.IsExpanded(property.Expression); if (property.ObjectGraphProperty.TargetNode != null) { ObjectGraphNode targetObjectNode = property.ObjectGraphProperty.TargetNode; PositionedGraphNode edgeTarget = treeNodeFor[targetObjectNode]; property.Edge = new TreeGraphEdge { IsTreeEdge = false, Name = property.Name, Source = property, Target = edgeTarget }; } } } resultGraph.Root = treeNodeFor[objectGraph.Root]; return(resultGraph); }
private PositionedGraphNodeControl addNodeToCanvas(PositionedGraphNode node) { canvas.Children.Add(node.NodeVisualControl); Canvas.SetLeft(node.NodeVisualControl, node.Left); Canvas.SetTop(node.NodeVisualControl, node.Top); return node.NodeVisualControl; }
internal void SetMatching(PositionedGraphNode matchFrom, PositionedGraphNode matchTo) { matching[matchFrom] = matchTo; changedNodes.Add(matchFrom); }
internal void SetRemoved(PositionedGraphNode removeddNode) { deletedNodes.Add(removeddNode); }
internal void SetAdded(PositionedGraphNode addedNode) { addedNodes.Add(addedNode); }
public PositionedGraphNode GetMatchingNewNode(PositionedGraphNode oldNode) { return matching.GetValue(oldNode); }
public ContentPropertyNode(PositionedGraphNode containingNode, ContentNode parent) : base(containingNode, parent) { }
public PositionedGraphNode GetMatchingNewNode(PositionedGraphNode oldNode) { return(matching.GetValue(oldNode)); }
private bool isSameAddress(PositionedGraphNode node1, PositionedGraphNode node2) { return(node1.ObjectNode.PermanentReference.GetObjectAddress() == node2.ObjectNode.PermanentReference.GetObjectAddress()); }
internal void AddNode(PositionedGraphNode node) { this.nodes.Add(node); }
private bool isSameAddress(PositionedGraphNode node1, PositionedGraphNode node2) { return node1.ObjectNode.PermanentReference.GetObjectAddress() == node2.ObjectNode.PermanentReference.GetObjectAddress(); }