/// <summary> /// Creates a DependencyGraph containing a copy of all the dependencies in the other graph /// Throws a ArgumentNullException if OtherGraph is null. /// </summary> /// <param name="OtherGraph">The other dependency graph from which the dependencies are copied</param> public DependencyGraph(DependencyGraph OtherGraph) { if (OtherGraph == null) { throw new ArgumentNullException("Argument(s) must be non-null"); } allNodes = new Dictionary <string, DependancyNode>(); foreach (DependancyNode n in OtherGraph.allNodes.Values) { DependancyNode NewNode; if (allNodes.ContainsKey(n.ToString())) { NewNode = allNodes[n.ToString()]; } else { NewNode = new DependancyNode(n.ToString()); allNodes.Add(NewNode.ToString(), NewNode); } foreach (DependancyNode n2 in n.GetDependees().Values) { DependancyNode NewDependee; if (allNodes.ContainsKey(n2.ToString())) { NewDependee = allNodes[n2.ToString()]; } else { NewDependee = new DependancyNode(n2.ToString()); allNodes.Add(NewDependee.ToString(), NewDependee); } NewNode.AddDependee(NewDependee); } foreach (DependancyNode n2 in n.GetDependents().Values) { DependancyNode NewDependent; if (allNodes.ContainsKey(n2.ToString())) { NewDependent = allNodes[n2.ToString()]; } else { NewDependent = new DependancyNode(n2.ToString()); allNodes.Add(NewDependent.ToString(), NewDependent); } NewNode.AddDependent(NewDependent); } } }