예제 #1
0
        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);
                }
            }
        }
예제 #2
0
        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);
        }