Beispiel #1
0
 /// <summary>
 /// Removes the linkedNode as a dependee of the node.
 /// </summary>
 public void RemoveDependee(DependencyNode linkedNode)
 {
     if (_linkedDependees.ContainsKey(linkedNode.ToString()))
     {
         _linkedDependees.Remove(linkedNode.ToString());
     }
 }
 /// <summary>
 /// Removes the dependency node if it is no longer being used.
 /// </summary>
 private void CleanUp(DependencyNode node)
 {
     if (node.CountDependents() == 0 && node.CountDependees() == 0)
     {
         _nodes.Remove(node.ToString());
     }
 }
Beispiel #3
0
 /// <summary>
 /// Adds the linkedNode as a dependency of the node.
 /// </summary>
 public void AddDependency(DependencyNode linkedNode)
 {
     if (HasDependency(linkedNode))
     {
         return;                            //Return if the link already exists.
     }
     _linkedDependency.Add(linkedNode.ToString(), linkedNode);
 }
        /// <summary>
        /// Removes all existing dependencies of the form (r,t).  Then, for each 
        /// s in newDependees, adds the dependency (s,t).
        /// Requires s != null and t != null. Throws an ArgumentNullException if s or t are null.
        /// </summary>
        public void ReplaceDependees(string t, IEnumerable<string> newDependees)
        {
            if (t == null) throw new ArgumentNullException(nameof(t));

            DependencyNode tNode = GetDependencyNode(t);
            tNode.ClearDependees();
            foreach (var newDependee in newDependees)
            {
                AddDependency(newDependee, tNode.ToString());
            }
            CleanUp(tNode);
        }
        /// <summary>
        /// Removes all existing dependencies of the form (s,r).  Then, for each
        /// t in newDependents, adds the dependency (s,t).
        /// Requires s != null and t != null. Throws an ArgumentNullException if s or t are null.
        /// </summary>
        public void ReplaceDependents(string s, IEnumerable<string> newDependents)
        {
            if (s == null) throw new ArgumentNullException(nameof(s));

            DependencyNode sNode = GetDependencyNode(s);
            sNode.ClearDependents();
            foreach (var newDependent in newDependents)
            {
                AddDependency(sNode.ToString(), newDependent);
            }
            CleanUp(sNode);
        }
Beispiel #6
0
 /// <summary>
 /// Returns true if the node has the dependee of sNode.
 /// </summary>
 public bool HasDependee(DependencyNode sNode)
 {
     return(_linkedDependees.ContainsKey(sNode.ToString()));
 }
Beispiel #7
0
 /// <summary>
 /// Returns true if the node has the dependency of tNode.
 /// </summary>
 public bool HasDependency(DependencyNode tNode)
 {
     return(_linkedDependency.ContainsKey(tNode.ToString()));
 }