Example #1
0
 public void addPostcondition(IRelation postcondition)
 {
     if (_postConditions.Contains(postcondition) == false)
     {
         _postConditions.Add(postcondition);
     }
     else
     {
         throw new System.ArgumentException("The precondition: " + postcondition.ToString() + " was already defined");
     }
 }
Example #2
0
 public void addRelation(IRelation r)
 {
     if (_relations.Contains(r))
     {
         throw new System.ArgumentException("Relation is already defined in the current state", r.ToString());
     }
     if (r.GetType() == typeof(UnaryRelation))
     {
         UnaryRelation ur = r as UnaryRelation;
         // check that the source entitiy in the relation is already part of the state
         if (_entities.Contains(ur.Source) == false)
         {
             throw new System.ArgumentException("Relation source " + ur.Source + " does not exist in this state");
         }
         // check that all the predicate in the relation is defined in the domain
         if (_domain.Predicates.Contains(ur.Predicate) == false)
         {
             throw new System.ArgumentException("Relation predicate " + ur.Predicate + " does not exist in this domain");
         }
     }
     if (r.GetType() == typeof(BinaryRelation))
     {
         BinaryRelation br = r as BinaryRelation;
         // check that the source and destination entitiy in the relation is already part of the state
         if (_entities.Contains(br.Source) == false)
         {
             throw new System.ArgumentException("Relation source " + br.Source + " does not exist in this state");
         }
         if (_entities.Contains(br.Destination) == false)
         {
             throw new System.ArgumentException("Relation destination " + br.Destination + " does not exist in this state");
         }
         // check that all the predicate in the relation is defined in the domain
         if (_domain.Predicates.Contains(br.Predicate) == false)
         {
             throw new System.ArgumentException("Relation predicate " + br.Predicate + " does not exist in this domain");
         }
     }
     _relations.Add(r);
 }