public override bool IsValid(params ILegalPerson[] persons) { var legalPerson = GetSubjectPerson(persons); if (legalPerson == null) { AddReasonEntry($"{nameof(GetSubjectPerson)} returned nothing"); return(false); } var lpPersonType = legalPerson.GetLegalPersonTypeName(); if (IsResponsibleForSituationArise != null && IsResponsibleForSituationArise(legalPerson)) { AddReasonEntry($"{lpPersonType}, {legalPerson.Name}, {nameof(IsResponsibleForSituationArise)} is true"); return(false); } if (!IsMultipleInHarm(legalPerson)) { AddReasonEntry($"{lpPersonType}, {legalPerson.Name}, {nameof(IsMultipleInHarm)} is false"); return(false); } if (Imminence != null && !Imminence.IsValid(legalPerson)) { AddReasonEntry($"{lpPersonType}, {legalPerson.Name}, {nameof(Imminence)} is false"); AddReasonEntryRange(Imminence.GetReasonEntries()); return(false); } if (Proportionality != null && !Proportionality.IsValid(legalPerson)) { AddReasonEntry($"{lpPersonType}, {legalPerson.Name}, {nameof(Proportionality)} is false"); AddReasonEntryRange(Proportionality.GetReasonEntries()); return(false); } AddReasonEntryRange(Imminence?.GetReasonEntries()); AddReasonEntryRange(Proportionality?.GetReasonEntries()); return(true); }
protected DefenseOfBase(Func <ILegalPerson[], ILegalPerson> getSubjectPerson) : base(getSubjectPerson) { Provocation = new Provocation(GetSubjectPerson); Imminence = new Imminence(GetSubjectPerson); Proportionality = new Proportionality <ITermCategory>(GetSubjectPerson); }