private void GetAncestorOrDescendantNodeEdge(DatabaseObject databaseObject, bool descendants, out ISet <DependencyNode> resultNodes, out ISet <DependencyEdge> resultEdges)
        {
            resultNodes = new HashSet <DependencyNode>();
            resultEdges = new HashSet <DependencyEdge>();
            ISet <DependencyEdge>  initValues = descendants ? _tables[databaseObject.ID].ChildEdges : _tables[databaseObject.ID].ParentEdges;
            Queue <DependencyEdge> toProcess  = new Queue <DependencyEdge>(initValues);

            while (toProcess.Count > 0)
            {
                DependencyEdge actualEdge = toProcess.Dequeue();
                if (resultEdges.Contains(actualEdge))
                {
                    continue;
                }
                ISet <DependencyEdge> searchValues = descendants ? actualEdge.Child.ChildEdges : actualEdge.Parent.ParentEdges;
                foreach (DependencyEdge edge in searchValues)
                {
                    if (!resultEdges.Contains(edge))
                    {
                        toProcess.Enqueue(edge);
                    }
                }
                resultEdges.Add(actualEdge);
                resultNodes.Add(descendants ? actualEdge.Child : actualEdge.Parent);
            }
            resultNodes.Remove(_tables[databaseObject.ID]); // start node is not descendant or ancestor
        }
Esempio n. 2
0
 public void AddDependencyEdge(DependencyEdge edge)
 {
     if (Equals(edge.Parent.DbObject, DbObject))
     {
         ChildEdges.Add(edge);
     }
     if (Equals(edge.Child.DbObject, DbObject))
     {
         ParentEdges.Add(edge);
     }
 }