Ejemplo n.º 1
0
        internal static bool IsHomicideConcurrance(IHomicideConcurrance hc, IRationale rationale, string defendantName = null, string title = null)
        {
            if (hc == null || rationale == null)
            {
                return(true);
            }
            title = title ?? "defendant";
            if (hc.TimeOfTheDeath != null && !hc.IsInRange(hc.TimeOfTheDeath.Value))
            {
                rationale.AddReasonEntry($"{title} {defendantName}, crime started " +
                                         $"at {hc.Inception.ToString("O")} and ended at {hc.Terminus?.ToString("O")}, " +
                                         $"{nameof(IHomicideConcurrance.TimeOfTheDeath)} at {hc.TimeOfTheDeath?.ToString("O")} is outside this range");
                return(false);
            }

            return(true);
        }
Ejemplo n.º 2
0
        public static IEnumerable <IAbsentee> Absentees(this IRationale lc, IEnumerable <ILegalPerson> persons)
        {
            var ppersons = persons == null ? new List <ILegalPerson>() : persons.ToList();

            if (lc == null || !ppersons.Any())
            {
                return(new List <IAbsentee>());
            }

            var absentees = ppersons.Where(p => p is IAbsentee).Cast <IAbsentee>().ToList();

            if (!absentees.Any())
            {
                var nameTitles = ppersons.GetTitleNamePairs();
                lc.AddReasonEntry($"No one is the {nameof(IAbsentee)} in {nameTitles}");
            }

            return(absentees);
        }
Ejemplo n.º 3
0
        public static IEnumerable <ILegalPerson> Cotenants(this IRationale lc, IEnumerable <ILegalPerson> persons)
        {
            var ppersons = persons == null ? new List <ILegalPerson>() : persons.ToList();

            if (lc == null || !ppersons.Any())
            {
                return(new List <ILegalPerson>());
            }

            var cotenants = ppersons.Where(p => p is ICotenant).ToList();

            if (!cotenants.Any())
            {
                var nameTitles = ppersons.GetTitleNamePairs();
                lc.AddReasonEntry($"No one is the {nameof(ICotenant)} in {nameTitles}");
            }

            return(cotenants);
        }
Ejemplo n.º 4
0
        public static ILessor Lessor(this IRationale lc, IEnumerable <ILegalPerson> persons)
        {
            var ppersons = persons == null ? new List <ILegalPerson>() : persons.ToList();

            if (lc == null || !ppersons.Any())
            {
                return(null);
            }

            var lessor = ppersons.Lessor() as ILessor;

            if (lessor == null)
            {
                var nameTitles = ppersons.GetTitleNamePairs();
                lc.AddReasonEntry($"No one is the {nameof(ILessor)} in {nameTitles}");
                return(null);
            }

            return(lessor);
        }
Ejemplo n.º 5
0
        public static IOfferee Offeree(this IRationale lc, IEnumerable <ILegalPerson> persons)
        {
            var ppersons = persons == null ? new List <ILegalPerson>() : persons.ToList();

            if (lc == null || !ppersons.Any())
            {
                return(null);
            }

            var offeree = ppersons.Offeree() as IOfferee;

            if (offeree == null)
            {
                var nameTitles = ppersons.GetTitleNamePairs();
                lc.AddReasonEntry($"No one is the {nameof(IOfferee)} in {nameTitles}");
                return(null);
            }

            return(offeree);
        }
Ejemplo n.º 6
0
        public static IThirdParty ThirdParty(this IRationale lc, IEnumerable <ILegalPerson> persons)
        {
            var ppersons = persons == null ? new List <ILegalPerson>() : persons.ToList();

            if (lc == null || !ppersons.Any())
            {
                return(null);
            }

            var thirdParty = ppersons.ThirdParty() as IThirdParty;

            if (thirdParty == null)
            {
                var nameTitles = ppersons.GetTitleNamePairs();
                lc.AddReasonEntry($"No one is the {nameof(IThirdParty)} in {nameTitles}");
                return(null);
            }

            return(thirdParty);
        }
Ejemplo n.º 7
0
        public static IVictim Victim(this IRationale lc, IEnumerable <ILegalPerson> persons)
        {
            var ppersons = persons == null ? new List <ILegalPerson>() : persons.ToList();

            if (lc == null || !ppersons.Any())
            {
                return(null);
            }

            var victim = ppersons.Victims().ToList();

            if (!victim.Any())
            {
                var nameTitles = ppersons.GetTitleNamePairs();
                lc.AddReasonEntry($"No one is the {nameof(IVictim)} in {nameTitles}");
                return(null);
            }

            return(victim.FirstOrDefault());
        }
Ejemplo n.º 8
0
        public static IDefendant Defendant(this IRationale lc, IEnumerable <ILegalPerson> persons)
        {
            var ppersons = persons == null ? new List <ILegalPerson>() : persons.ToList();

            if (lc == null || !ppersons.Any())
            {
                return(null);
            }

            var defendant = ppersons.Defendant() as IDefendant;

            if (defendant == null)
            {
                var nameTitles = ppersons.GetTitleNamePairs();
                lc.AddReasonEntry($"No one is the {nameof(IDefendant)} in {nameTitles}");
                return(null);
            }

            return(defendant);
        }
Ejemplo n.º 9
0
        public static IPlaintiff Plaintiff(this IRationale lc, IEnumerable <ILegalPerson> persons)
        {
            var ppersons = persons == null ? new List <ILegalPerson>() : persons.ToList();

            if (lc == null || !ppersons.Any())
            {
                return(null);
            }

            var plaintiff = ppersons.Plaintiff() as IPlaintiff;

            if (plaintiff == null)
            {
                var nameTitles = ppersons.GetTitleNamePairs();
                lc.AddReasonEntry($"No one is the {nameof(IPlaintiff)} in {nameTitles}");
                return(null);
            }

            return(plaintiff);
        }
Ejemplo n.º 10
0
        public static ILawEnforcement LawEnforcement(this IRationale lc, IEnumerable <ILegalPerson> persons, Func <ILegalPerson[], ILegalPerson> func)
        {
            func = func ?? (lps => lps.LawEnforcement());
            var ppersons = persons == null ? new ILegalPerson[] { } : persons.ToArray();

            if (lc == null || !ppersons.Any())
            {
                return(null);
            }

            var lawEnforcement = func(ppersons) as ILawEnforcement;

            if (lawEnforcement == null)
            {
                var nameTitles = ppersons.GetTitleNamePairs();
                lc.AddReasonEntry($"No one is the {nameof(ILawEnforcement)} in {nameTitles}");
                return(null);
            }

            return(lawEnforcement);
        }
Ejemplo n.º 11
0
        public static bool PropertyOwnerIsInPossession(this IRationale lc, ILegalProperty SubjectProperty, ILegalPerson subj)
        {
            if (subj == null)
            {
                return(false);
            }
            var title = subj.GetLegalPersonTypeName();

            if (SubjectProperty == null)
            {
                lc.AddReasonEntry($"{title} {subj.Name}, {nameof(SubjectProperty)} is unassigned");
                return(false);
            }

            var hasPossession = SubjectProperty.IsInPossessionOf != null && SubjectProperty.IsInPossessionOf(subj);
            var isIsNot       = hasPossession ? "is in possession" : "is not in possession";

            lc.AddReasonEntry(
                $"{title} {subj.Name}, {isIsNot} " +
                $"of {SubjectProperty.GetType().Name} " +
                $"named '{SubjectProperty.Name}'");

            return(hasPossession);
        }
Ejemplo n.º 12
0
        public static bool PropertyOwnerIsSubjectPerson(this IRationale lc, ILegalProperty property, ILegalPerson person)
        {
            if (person == null)
            {
                return(false);
            }
            var title = person.GetLegalPersonTypeName();

            if (property == null)
            {
                lc.AddReasonEntry($"{title} {person.Name}, {nameof(property)} is unassigned");
                return(false);
            }

            var isOwner = property.IsEntitledTo != null && property.IsEntitledTo(person);
            var isIsNot = isOwner ? "is owner" : "is not owner";

            lc.AddReasonEntry(
                $"{title} {person.Name}, {isIsNot} " +
                $"of {property.GetType().Name} " +
                $"named '{property.Name}'");

            return(isOwner);
        }
Ejemplo n.º 13
0
        public static ISet <Term <T> > GetAdditionalTerms(ISet <Term <T> > sorTerms, ISet <Term <T> > seeTerms, IRationale reasoning = null)
        {
            var additionalTerms = new HashSet <Term <T> >();
            var agreedTermNames = GetInNameAgreedTerms(sorTerms, seeTerms);

            sorTerms.ExceptWith(agreedTermNames);
            seeTerms.ExceptWith(agreedTermNames);

            foreach (var sorTerm in sorTerms)
            {
                additionalTerms.Add(sorTerm);
            }
            foreach (var seeTerm in seeTerms)
            {
                additionalTerms.Add(seeTerm);
            }

            if (!additionalTerms.Any())
            {
                reasoning?.AddReasonEntry("there is not additional terms present between");
            }

            return(additionalTerms);
        }
Ejemplo n.º 14
0
        public static ISet <Term <T> > GetInNameAgreedTerms(ISet <Term <T> > sorTerms, ISet <Term <T> > seeTerms, IRationale reasoning = null)
        {
            if (sorTerms == null || seeTerms == null)
            {
                reasoning?.AddReasonEntry("one of the set of terms is missing.");
                return(new HashSet <Term <T> >());
            }

            var agreedList = sorTerms.Where(oo => seeTerms.Any(ee => ee.Equals(oo))).ToList();

            if (!agreedList.Any())
            {
                reasoning?.AddReasonEntry("there are no terms shared");
                return(new HashSet <Term <T> >());
            }
            var agreedTerms = new HashSet <Term <T> >();

            foreach (var t in agreedList)
            {
                agreedTerms.Add(t);
            }

            return(agreedTerms);
        }
Ejemplo n.º 15
0
        public static ISet <Term <T> > GetAgreedTerms(ISet <Term <T> > sorTerms, ISet <Term <T> > seeTerms, IRationale reasoning = null)
        {
            var agreedTerms     = new HashSet <Term <T> >();
            var agreedTermNames = GetInNameAgreedTerms(sorTerms, seeTerms, reasoning).Select(v => v.Name);

            if (!agreedTermNames.Any())
            {
                return(agreedTerms);
            }

            ThrowOnDupRefersTo(sorTerms);
            ThrowOnDupRefersTo(seeTerms);

            foreach (var termName in agreedTermNames)
            {
                var offerorTerm = sorTerms.First(v => v.Name == termName);
                var offereeTerm = seeTerms.First(v => v.Name == termName);

                if (!offereeTerm?.EqualRefersTo(offerorTerm) ?? false)
                {
                    reasoning?.AddReasonEntry($"the term '{termName}' does not have the same meaning");
                    continue;
                }
                agreedTerms.Add(offerorTerm);
            }

            return(agreedTerms);
        }