using Deltares.Dam.Data; namespace Deltares.Standard.Specifications { public class OrSpecification : CompositeSpecification { private readonly ISpecification one; private readonly ISpecification other; public OrSpecification(ISpecification one, ISpecification other) { this.one = one; this.other = other; } /// /// Determines whether the candidate satisfies the specification. /// /// The candidate to test. /// /// true if the candidate satisfies the specification otherwise, false. /// public override bool IsSatisfiedBy(TCandidate candidate) { bool otherIsSatisfiedBy = other.IsSatisfiedBy(candidate); bool thisIsSatisfiedBy = one.IsSatisfiedBy(candidate); bool isSatisfied = (thisIsSatisfiedBy || otherIsSatisfiedBy); if (!isSatisfied) { Description = "This " + one.Description + " AND " + other.Description + " are not satisfied"; } return isSatisfied; } } }