public override string ToString() { string value = ""; value += "ENTITY TYPES:\n"; foreach (EntityType et in _entityTypes) { value += et.ToString() + "\n"; } value += "\nPREDICATES:\n"; foreach (IPredicate p in _predicates) { if (p.GetType() == typeof(UnaryPredicate)) { UnaryPredicate up = p as UnaryPredicate; value += up.ToString() + "\n"; } else if (p.GetType() == typeof(BinaryPredicate)) { BinaryPredicate bp = p as BinaryPredicate; value += bp.ToString() + "\n"; } } value += "\nACTIONS:\n"; foreach (Action a in _actions) { value += a.ToString() + "\n"; } return(value); }
public UnaryRelation(Entity source, IPredicate predicate, RelationValue value) { if (source == null) { throw new System.ArgumentNullException("Relation source cannot be null", "source"); } if (predicate == null) { throw new System.ArgumentNullException("Relation predicate cannot be null", "predicate"); } if (predicate.GetType() != typeof(UnaryPredicate)) { throw new System.ArgumentNullException("Unary relation predicate must be a unary predicate", "predicate"); } UnaryPredicate unaryPredicate = predicate as UnaryPredicate; if (source.Type.Equals(predicate.Source) == false) { throw new System.ArgumentException("Relation source is not of the specified predicate type", source + " " + predicate.Source); } _source = source; _predicate = unaryPredicate; _value = value; }
public UnaryRelation generateRelationFromPredicateName(string name, Entity source, RelationValue value) { UnaryRelation relation = null; UnaryPredicate up = null; IPredicate p = getPredicate(name); if (p.GetType() == typeof(UnaryPredicate)) { up = p as UnaryPredicate; relation = new UnaryRelation(source, up, value); } else { throw new System.ArgumentException("The specified Predicate name is not UnaryPredicate", "generateRelationFromPredicateName(name, source)"); } return(relation); }
public override bool Equals(object obj) { if (obj == null) { return(false); } if (obj.GetType() != typeof(UnaryPredicate)) { return(false); } UnaryPredicate otherPredicate = obj as UnaryPredicate; if (_source.Equals(otherPredicate.Source) == false) { return(false); } if (_name.Equals(otherPredicate.Name) == false) { return(false); } return(true); }