protected internal bool TryGetTerms(ILegalPerson offeror, ILegalPerson offeree) { if (offeror == null || offeree == null) { AddReasonEntry("cannot resolve contract terms with both and offeror and offeree"); return(false); } if (Contract?.Assent == null) { AddReasonEntry("resolving ambiguous terms requires a contract with assent"); return(false); } var contractTerms = Contract.Assent as IAssentTerms; if (contractTerms == null) { AddReasonEntry("resolving ambiguous terms requires a contract with assent"); return(false); } AgreedTerms = contractTerms.GetInNameAgreedTerms(offeror, offeree); AddReasonEntryRange(Contract.Assent.GetReasonEntries()); if (!AgreedTerms.Any()) { AddReasonEntry($"there are not agreed terms between {offeror.Name} and {offeree.Name}"); return(false); } OfferorTerms = contractTerms.TermsOfAgreement(offeror); OffereeTerms = contractTerms.TermsOfAgreement(offeree); return(true); }
public override bool IsValid(params ILegalPerson[] persons) { var offeror = this.Offeror(persons); var offeree = this.Offeree(persons); if (offeree == null || offeror == null) { return(false); } if (!TryGetTerms(offeror, offeree)) { return(false); } var conditionalTerms = AgreedTerms.Where(t => IsConditionalTerm(t)).ToList(); if (!conditionalTerms.Any()) { AddReasonEntry($"There are no conditional precedent terms between {offeror.Name} and {offeree.Name}"); return(false); } foreach (var ct in conditionalTerms) { var isNotMet = IsNotConditionMet(ct, offeror) || IsNotConditionMet(ct, offeree); if (isNotMet) { AddReasonEntry($"there is a conditional precedent between {offeror.Name} " + $"and {offeree.Name}, '{ct}', which has not been met."); return(false); } } return(true); }
public override bool IsValid(params ILegalPerson[] persons) { var offeror = this.Offeror(persons); var offeree = this.Offeree(persons); if (offeree == null || offeror == null) { return(false); } if (!TryGetTerms(offeror, offeree)) { return(false); } var preque = IsPrerequisite ?? (t => true); if (AgreedTerms.All(agreedTerm => !preque(agreedTerm))) { AddReasonEntry($"none of the terms between {offeror.Name} and {offeree.Name} " + "satisfied the prerequisite condition."); return(false); } var resolved = new List <bool>(); foreach (var term in AgreedTerms) { var offerorTerm = OfferorTerms.First(v => v.Name == term.Name); var offereeTerm = OffereeTerms.First(v => v.Name == term.Name); var isSemanticConflict = !offereeTerm.EqualRefersTo(offerorTerm); //try it both ways if (!isSemanticConflict) { isSemanticConflict = !offerorTerm.EqualRefersTo(offereeTerm); } if (!isSemanticConflict) { continue; } var isOfferorPreferred = IsIntendedMeaningAtTheTime(offerorTerm); var isOffereePreferred = IsIntendedMeaningAtTheTime(offereeTerm); var isOneOnlyOneValid = isOfferorPreferred ^ isOffereePreferred; if (!isOneOnlyOneValid) { AddReasonEntry($"the term '{offereeTerm.Name}' has two different " + $"meanings and neither {offeror.Name}'s " + $"nor {offeree.Name}'s is preferred "); } if (isOfferorPreferred) { AddReasonEntry($"the preferred meaning of '{offereeTerm.Name}' is " + $"the one given by {offeror.Name} and NOT " + $"the one given by {offeree.Name}"); } if (isOffereePreferred) { AddReasonEntry($"the preferred meaning of '{offereeTerm.Name}' is " + $"the one given by {offeree.Name} and NOT " + $"the one given by {offeror.Name}"); } resolved.Add(isOneOnlyOneValid); } return(resolved.Any() && resolved.All(v => v)); }