private void NotifyAddition(CriterionNode node)
 {
     if (criterionAddedCallback != null)
     {
         criterionAddedCallback(node);
     }
 }
 public void Remove(CriterionNode node)
 {
     if (List.Contains(node))
     {
         List.Remove(node);
     }
 }
 private void NotifyRemoval(CriterionNode node)
 {
     if (criterionRemovedCallback != null)
     {
         criterionRemovedCallback(node);
     }
 }
Пример #4
0
 private void HandleChildCriterionRemoved(CriterionNode node)
 {
     if (Object.ReferenceEquals(node.ParentCriterionNode, this))
     {
         node.ParentCriterionNode = null;
     }
 }
Пример #5
0
        /// <summary>
        /// Returns AlternativeNode object by Alternative and CriterionNode objects
        /// </summary>
        /// <param name="alternative"></param>
        /// <param name="criterion"></param>
        /// <returns></returns>
        public AlternativeNode this[Alternative alternative, CriterionNode criterion]
        {
            get
            {
                if (!Alternatives.Contains(alternative))
                {
                    throw new KeyNotFoundException(String.Format("Alternative '{0}' not found in the Altenatives collection of the hierarchy", alternative.Name));
                }

                ICollection <CriterionNode> nodes = GoalNode.GetLowestCriterionNodes();
                if (!nodes.Contains(criterion))
                {
                    throw new KeyNotFoundException(String.Format("Criterion node '{0}' not found in the criterion nodes which are at lowest level of the hierarchy", criterion.Name));
                }

                RefreshAlternativeNodes();

                AlternativeNode result = null;
                foreach (CriterionNode node in nodes)
                {
                    foreach (AlternativeNode alternativeNode in node.AlternativeNodes)
                    {
                        if (Object.ReferenceEquals(node, criterion) &&
                            Object.ReferenceEquals(alternativeNode.Alternative, alternative))
                        {
                            result = alternativeNode;
                        }
                    }
                }

                return(result);
            }
        }
Пример #6
0
 private void HandleChildAdded(CriterionNode node)
 {
     if (!Object.ReferenceEquals(node.GoalNode, this))
     {
         node.GoalNode = this;
     }
 }
        public CriterionNode Add(string name, decimal weight)
        {
            CriterionNode node = new CriterionNode(name, weight);

            this.Add(node);

            return(node);
        }
Пример #8
0
 private void HandleChildCriterionAdded(CriterionNode node)
 {
     if (!Object.ReferenceEquals(node.ParentCriterionNode, this))
     {
         node.ParentCriterionNode = this;
     }
     this.AlternativeNodes.Clear();
 }
        protected override void OnClear()
        {
            CriterionNode[] toBeCleared = new CriterionNode[List.Count];
            List.CopyTo(toBeCleared, 0);

            foreach (CriterionNode node in toBeCleared)
            {
                NotifyRemoval(node);
            }
        }
 public int Add(CriterionNode node)
 {
     if (!List.Contains(node))
     {
         return(List.Add(node));
     }
     else
     {
         return(List.IndexOf(node));
     }
 }
Пример #11
0
 private void LookForLowestCriterionNodes(CriterionNode node, ICollection <CriterionNode> nodes)
 {
     if (node.HasSubcriterionNodes)
     {
         foreach (CriterionNode subcriterionNode in node.SubcriterionNodes)
         {
             LookForLowestCriterionNodes(subcriterionNode, nodes);
         }
     }
     else
     {
         nodes.Add(node);
     }
 }
 public bool Contains(CriterionNode node)
 {
     return(List.Contains(node));
 }