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