示例#1
0
 private void HandleAlternativeRemoved(AlternativeNode node)
 {
     if (Object.ReferenceEquals(node.CriterionNode, this))
     {
         node.CriterionNode = null;
     }
 }
示例#2
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);
            }
        }
示例#3
0
 public void Remove(AlternativeNode node)
 {
     if (List.Contains(node))
     {
         List.Remove(node);
     }
 }
示例#4
0
 private void NotifyRemoval(AlternativeNode node)
 {
     if (alternativeRemovedCallback != null)
     {
         alternativeRemovedCallback(node);
     }
 }
示例#5
0
 private void NotifyAddition(AlternativeNode node)
 {
     if (alternativeAddedCallback != null)
     {
         alternativeAddedCallback(node);
     }
 }
示例#6
0
 private void HandleAlternativeAdded(AlternativeNode node)
 {
     if (!Object.ReferenceEquals(node.CriterionNode, this))
     {
         node.CriterionNode = this;
     }
     this.SubcriterionNodes.Clear();
 }
示例#7
0
 private void HandleAlternativeRemoved(Alternative alternative)
 {
     foreach (CriterionNode lowestCriterionNode in goalNode.GetLowestCriterionNodes())
     {
         AlternativeNode toBeDeleted = lowestCriterionNode.AlternativeNodes[alternative];
         lowestCriterionNode.AlternativeNodes.Remove(toBeDeleted);
     }
 }
示例#8
0
        protected override void OnClear()
        {
            AlternativeNode[] toBeCleared = new AlternativeNode[List.Count];
            List.CopyTo(toBeCleared, 0);

            foreach (AlternativeNode node in toBeCleared)
            {
                NotifyRemoval(node);
            }
        }
示例#9
0
        public int Add(AlternativeNode node)
        {
            if (!List.Contains(node))
            {
                if (this[node.Alternative] != null)
                {
                    throw new ArgumentException("AlternativeNode with the same value of Alternative property has already been added");
                }

                return(List.Add(node));
            }
            else
            {
                return(List.IndexOf(node));
            }
        }
示例#10
0
 public bool Contains(AlternativeNode node)
 {
     return(List.Contains(node));
 }