Example #1
0
        public static bool operator >(Criterion l, Criterion r)
        {
            if ((object)l == (object)r)
            {
                return(false);
            }

            if ((object)l == null)
            {
                return(false);
            }

            if ((object)r == null)
            {
                return(true);
            }

            try
            {
                CriterionOrdering.OrderingRelation relation = l.GetRelationTo(r);

                return(true);
            }
            catch (RelationshipError)
            {
                CriterionOrdering.OrderingRelation relation = r.GetRelationTo(l);

                return(false);
            }
        }
Example #2
0
        public void AddCriterionOrdering(
            CriterionOrdering.OrderingRelation relation,
            Criterion criterion)
        {
            if (!CriterionOrderings.Equals(criterion.CriterionOrderings))
            {
                throw new RelationshipError();
            }

            if (CriterionOrderings.ContainsKey(Name))
            {
                throw new RelationshipError();
            }

            CriterionOrderings.Add(
                Name,
                new CriterionOrdering(this, relation, criterion));
        }
Example #3
0
        CreateCriterionOrdering(
            string name1,
            CriterionOrdering.OrderingRelation relation,
            string name2)
        {
            if (!Criteria.ContainsKey(name1))
            {
                throw new UnknownCriterionError();
            }

            if (!Criteria.ContainsKey(name2))
            {
                throw new UnknownCriterionError();
            }

            Criteria[name1].AddCriterionOrdering(
                relation,
                Criteria[name2]);
        }
Example #4
0
        public CriterionOrdering.OrderingRelation GetRelationTo(
            Criterion c)
        {
            if (CriterionOrderings != c.CriterionOrderings)
            {
                throw new RelationshipError();
            }

            // First check relation between this and c

            CriterionOrdering.OrderingRelation greatestRelation = CriterionOrdering.OrderingRelation.IsEqualTo;

            string Next = Name;

            while (true)
            {
                if (!CriterionOrderings.ContainsKey(Next))
                {
                    break;
                }

                CriterionOrdering co = CriterionOrderings[Next];

                if (co.Relation > greatestRelation)
                {
                    greatestRelation = co.Relation;
                }

                if (co.Right.Name == c.Name)
                {
                    return(greatestRelation);
                }

                Next = co.Right.Name;
            }

            throw new RelationshipError();
        }