コード例 #1
0
        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);
        }
コード例 #2
0
        public ContentNode(PositionedGraphNode containingNode, ContentNode parent)
        {
            if (containingNode == null)
            {
                throw new ArgumentNullException("containingNode");
            }

            this.containingNode = containingNode;
            this.parent         = parent;
        }
コード例 #3
0
		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;
			}
		}
コード例 #4
0
        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);
            }
        }
コード例 #5
0
        /// <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;
        }
コード例 #6
0
        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);
        }
コード例 #7
0
		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;
		}
コード例 #8
0
ファイル: GraphDiff.cs プロジェクト: Bombadil77/SharpDevelop
		internal void SetMatching(PositionedGraphNode matchFrom, PositionedGraphNode matchTo)
		{
			matching[matchFrom] = matchTo;
			changedNodes.Add(matchFrom);
		}
コード例 #9
0
ファイル: GraphDiff.cs プロジェクト: Bombadil77/SharpDevelop
		internal void SetRemoved(PositionedGraphNode removeddNode)
		{
			deletedNodes.Add(removeddNode);
		}
コード例 #10
0
ファイル: GraphDiff.cs プロジェクト: Bombadil77/SharpDevelop
		internal void SetAdded(PositionedGraphNode addedNode)
		{
			addedNodes.Add(addedNode);
		}
コード例 #11
0
ファイル: GraphDiff.cs プロジェクト: Bombadil77/SharpDevelop
		public PositionedGraphNode GetMatchingNewNode(PositionedGraphNode oldNode)
		{
			return matching.GetValue(oldNode);
		}
コード例 #12
0
 public ContentPropertyNode(PositionedGraphNode containingNode, ContentNode parent)
     : base(containingNode, parent)
 {
 }
コード例 #13
0
 public PositionedGraphNode GetMatchingNewNode(PositionedGraphNode oldNode)
 {
     return(matching.GetValue(oldNode));
 }
コード例 #14
0
 internal void SetAdded(PositionedGraphNode addedNode)
 {
     addedNodes.Add(addedNode);
 }
コード例 #15
0
 internal void SetRemoved(PositionedGraphNode removeddNode)
 {
     deletedNodes.Add(removeddNode);
 }
コード例 #16
0
 private bool isSameAddress(PositionedGraphNode node1, PositionedGraphNode node2)
 {
     return(node1.ObjectNode.PermanentReference.GetObjectAddress() == node2.ObjectNode.PermanentReference.GetObjectAddress());
 }
コード例 #17
0
 internal void AddNode(PositionedGraphNode node)
 {
     this.nodes.Add(node);
 }
コード例 #18
0
 internal void SetMatching(PositionedGraphNode matchFrom, PositionedGraphNode matchTo)
 {
     matching[matchFrom] = matchTo;
     changedNodes.Add(matchFrom);
 }
コード例 #19
0
		private bool isSameAddress(PositionedGraphNode node1, PositionedGraphNode node2)
		{
			return node1.ObjectNode.PermanentReference.GetObjectAddress() == node2.ObjectNode.PermanentReference.GetObjectAddress();
		}
コード例 #20
0
		internal void AddNode(PositionedGraphNode node)
		{
			this.nodes.Add(node);
		}