public void AddCaseTarget( CaseType caseValue, DecisionGraphNode target) { CaseImpl ci = null; if (this.mCases.Count == 0) { ci = new CaseImpl(caseValue); ci.Targets.Add(target); this.mCases.Add(ci); } else { int i; EqualityComparer <CaseType> ec = EqualityComparer <CaseType> .Default; for (i = this.mCases.Count - 1; i >= 0; i--) { ci = this.mCases[i]; if (ec.Equals(caseValue, ci.Value)) { break; } } if (i < 0) { ci = new CaseImpl(caseValue); this.mCases.Add(ci); } if (!ci.Targets.Contains(target)) { ci.Targets.Add(target); } } }
public bool RemoveCaseTarget( CaseType caseValue, DecisionGraphNode target) { if (this.mCases.Count == 0) { return(false); } int i; CaseImpl ci = null; EqualityComparer <CaseType> ec = EqualityComparer <CaseType> .Default; for (i = this.mCases.Count - 1; i >= 0; i--) { ci = this.mCases[i]; if (ec.Equals(caseValue, ci.Value)) { break; } } if (i < 0) { return(false); } int index = ci.Targets.IndexOf(target); if (index < 0) { return(false); } ci.Targets.RemoveAt(index); if (ci.Targets.Count == 0) { this.mCases.RemoveAt(i); } return(true); }