public List <IGeneticTreeNode> GetInheritors(IGeneticTreeNode person) { List <IGeneticTreeNode> list = new List <IGeneticTreeNode>(); AddInheritors(list, person); return(list); }
public void GetSomeonesAncestors(List <IGeneticTreeNode> ancestors, IGeneticTreeNode person) { foreach (var item in GetParents(person)) { ancestors.Add(item); GetSomeonesAncestors(ancestors, item); } }
public bool CheckFatherRelation(IGeneticTreeNode father, IGeneticTreeNode child) { return father.Name != child.Name && father.Sex == Sex.Male && father.DateOfBirth.AddYears(12) < child.DateOfBirth && father.DateOfBirth.AddYears(70) > child.DateOfBirth && ((father.DateOfDead == null) || father.DateOfDead.Value.AddDays(270) > child.DateOfBirth); }
public void GetSomeonesDescendants(List <IGeneticTreeNode> descendants, IGeneticTreeNode person) { foreach (var item in person.Children) { descendants.Add(item); GetSomeonesDescendants(descendants, item); } }
public bool CheckFatherRelation(IGeneticTreeNode father, IGeneticTreeNode child) { return(father.Name != child.Name && father.Sex == Sex.Male && father.DateOfBirth.AddYears(12) < child.DateOfBirth && father.DateOfBirth.AddYears(70) > child.DateOfBirth && ((father.DateOfDead == null) || father.DateOfDead.Value.AddDays(270) > child.DateOfBirth)); }
public bool CheckMotherRelation(IGeneticTreeNode mother, IGeneticTreeNode child) { return mother.Name != child.Name && mother.Sex == Sex.Female && !mother.Children.Contains(child) && GetParent(Sex.Female, child) == null && mother.DateOfBirth.AddYears(10) < child.DateOfBirth && mother.DateOfBirth.AddYears(60) > child.DateOfBirth && ((mother.DateOfDead == null) || (mother.DateOfDead.Value > child.DateOfBirth)); }
public List <IGeneticTreeNode> GetCommonAncestors(IGeneticTreeNode person1, IGeneticTreeNode person2) { var family1 = new List <IGeneticTreeNode>(); var family2 = new List <IGeneticTreeNode>(); GetSomeonesAncestors(family1, person1); GetSomeonesAncestors(family2, person2); return(family1.Intersect <IGeneticTreeNode>(family2).ToList()); }
public bool CheckMotherRelation(IGeneticTreeNode mother, IGeneticTreeNode child) { return(mother.Name != child.Name && mother.Sex == Sex.Female && !mother.Children.Contains(child) && GetParent(Sex.Female, child) == null && mother.DateOfBirth.AddYears(10) < child.DateOfBirth && mother.DateOfBirth.AddYears(60) > child.DateOfBirth && ((mother.DateOfDead == null) || (mother.DateOfDead.Value > child.DateOfBirth))); }
private void AddInheritors(List <IGeneticTreeNode> inheritors, IGeneticTreeNode person) { foreach (var item in person.Children) { if (item.DateOfDead != null) { AddInheritors(inheritors, item); } else { inheritors.Add(item); } } }
public List <IGeneticTreeNode> GetParents(IGeneticTreeNode person) { var list = new List <IGeneticTreeNode>(); var parent1 = GetParent(Sex.Male, person); if (parent1 != null) { list.Add(parent1); } var parent2 = GetParent(Sex.Female, person); if (parent2 != null) { list.Add(parent2); } return(list); }
private void AddToGeneration(int level, IGeneticTreeNode node) { var generation = GetGeneration(level); if (generation == null) { Generations.Add(new Generation() { Level = level, Nodes = new List <IGeneticTreeNode>() }); generation = GetGeneration(level); } if (!generation.Nodes.Contains(node)) { AddToGeneration(generation, node); } }
public bool ChangeDateOfBirth(IGeneticTreeNode person) { var parent = new Person() { DateOfBirth = person.DateOfBirth, DateOfDead = person.DateOfDead, }; if (person.Children != null) { if (person.Children.Any(child => !CheckPartensDateOfBirth(parent, child))) { return(false); } } return(true); }
public bool ChangeDateOfDead(DateTime?newDate, IGeneticTreeNode person) { var parent = new Person() { DateOfBirth = person.DateOfBirth, DateOfDead = newDate, }; if (person.Children != null) { if (person.Children.Any(child => !CheckChildRelation(child, parent))) { return(false); } } person.DateOfDead = newDate; return(true); }
public bool CheckMothersDateOfBirth(IGeneticTreeNode parent, IGeneticTreeNode child) { return(child.DateOfBirth > parent.DateOfBirth.AddYears(10)); }
private void AddToGeneration(Generation generation, IGeneticTreeNode node, IGeneticTreeNode to) { generation.Nodes.Insert(GetIndexInGeneration(generation, to), node); }
private int GetIndexInGeneration(Generation generation, IGeneticTreeNode node) { return(generation.Nodes.IndexOf(node)); }
private bool GotChildrenWithSomeonesChild(IGeneticTreeNode node) { return(Nodes.Where(n => n != node).Any(n => n.Children.ContainsAny <IGeneticTreeNode>(node.Children))); }
public Person GetParent(Sex sex, IGeneticTreeNode person) { var parent = this._db.Query<Person>(n => n.Sex == sex && n.Children.Contains(person)).FirstOrDefault(); return parent; }
public IEnumerable <Person> GetAllMothers(IGeneticTreeNode child) { return(this._db.Query <Person>().Where(n => CheckMotherRelation(n, child))); }
public List<IGeneticTreeNode> GetCommonAncestors(IGeneticTreeNode person1, IGeneticTreeNode person2) { var family1 = new List<IGeneticTreeNode>(); var family2 = new List<IGeneticTreeNode>(); GetSomeonesAncestors(family1, person1); GetSomeonesAncestors(family2, person2); return family1.Intersect<IGeneticTreeNode>(family2).ToList(); }
public void GetSomeonesDescendants(List<IGeneticTreeNode> descendants, IGeneticTreeNode person) { foreach (var item in person.Children) { descendants.Add(item); GetSomeonesDescendants(descendants, item); } }
public void GetSomeonesAncestors(List<IGeneticTreeNode> ancestors, IGeneticTreeNode person) { foreach (var item in GetParents(person)) { ancestors.Add(item); GetSomeonesAncestors(ancestors, item); } }
public List<IGeneticTreeNode> GetInheritors(IGeneticTreeNode person) { List<IGeneticTreeNode> list = new List<IGeneticTreeNode>(); AddInheritors(list, person); return list; }
private void AddInheritors(List<IGeneticTreeNode> inheritors, IGeneticTreeNode person) { foreach (var item in person.Children) { if (item.DateOfDead!=null) { AddInheritors(inheritors, item); } else { inheritors.Add(item); } } }
public IEnumerable<Person> GetAllChildren(IGeneticTreeNode parent) { return this._db.Query<Person>().Where(n => CheckChildRelationWithChildEntity(n, parent)); }
public IEnumerable<Person> GetAllMothers(IGeneticTreeNode child) { return this._db.Query<Person>().Where(n => CheckMotherRelation(n, child)); }
public bool ChangeDateOfDead(DateTime? newDate, IGeneticTreeNode person) { var parent = new Person() { DateOfBirth = person.DateOfBirth, DateOfDead = newDate, }; if (person.Children != null) { if (person.Children.Any(child => !CheckChildRelation(child, parent))) { return false; } } person.DateOfDead = newDate; return true; }
public Person GetParent(Sex sex, IGeneticTreeNode person) { var parent = this._db.Query <Person>(n => n.Sex == sex && n.Children.Contains(person)).FirstOrDefault(); return(parent); }
public bool CheckChildRelationWithChildEntity(IGeneticTreeNode child, IGeneticTreeNode parent) { return (parent.Sex == Sex.Male) ? CheckFatherRelationWithChildEntity(parent, child) : CheckMotherRelationWithChildEntity(parent, child); }
public bool CheckFatherRelationWithChildEntity(IGeneticTreeNode father, IGeneticTreeNode child) { return(CheckFatherRelation(father, child) && !father.Children.Contains(child) && GetParent(Sex.Male, child) == null); }
private bool GotParents(IGeneticTreeNode node) { return(Nodes.Any(n => n.Children.Contains(node))); }
public IEnumerable <Person> GetAllChildren(IGeneticTreeNode parent) { return(this._db.Query <Person>().Where(n => CheckChildRelationWithChildEntity(n, parent))); }
public bool CheckPartensDateOfBirth(IGeneticTreeNode parent, IGeneticTreeNode child) { return (parent.Sex == Sex.Male) ? CheckFathersDateOfBirth(parent, child) : CheckMothersDateOfBirth(parent, child); }
private IGeneticTreeNode GetPartner(IGeneticTreeNode node) { return(Nodes.SingleOrDefault(n => n != node && n.Children.ContainsAny <IGeneticTreeNode>(node.Children))); }
private void AddToGeneration(Generation generation, IGeneticTreeNode node) { generation.Nodes.Add(node); }
private bool GotChildren(IGeneticTreeNode node) { return(node.Children.Count > 0); }
private Generation GetSomeonesGeneration(IGeneticTreeNode node) { return(Generations.SingleOrDefault(n => n.Nodes.Contains(node))); }
public bool CheckChildRelationWithChildEntity(IGeneticTreeNode child, IGeneticTreeNode parent) { return((parent.Sex == Sex.Male) ? CheckFatherRelationWithChildEntity(parent, child) : CheckMotherRelationWithChildEntity(parent, child)); }
public bool CheckFatherRelationWithChildEntity(IGeneticTreeNode father, IGeneticTreeNode child) { return CheckFatherRelation(father, child) && !father.Children.Contains(child) && GetParent(Sex.Male, child) == null; }
public bool CheckPartensDateOfBirth(IGeneticTreeNode parent, IGeneticTreeNode child) { return((parent.Sex == Sex.Male) ? CheckFathersDateOfBirth(parent, child) : CheckMothersDateOfBirth(parent, child)); }
public List<IGeneticTreeNode> GetParents(IGeneticTreeNode person) { var list = new List<IGeneticTreeNode>(); var parent1 = GetParent(Sex.Male, person); if (parent1 != null) { list.Add(parent1); } var parent2 = GetParent(Sex.Female, person); if (parent2 != null) { list.Add(parent2); } return list; }
public bool CheckMothersDateOfBirth(IGeneticTreeNode parent, IGeneticTreeNode child) { return child.DateOfBirth > parent.DateOfBirth.AddYears(10); }
public bool ChangeDateOfBirth(IGeneticTreeNode person) { var parent = new Person() { DateOfBirth = person.DateOfBirth, DateOfDead = person.DateOfDead, }; if (person.Children != null) { if (person.Children.Any(child => !CheckPartensDateOfBirth(parent, child))) { return false; } } return true; }
public bool CheckMotherRelationWithChildEntity(IGeneticTreeNode mother, IGeneticTreeNode child) { return CheckMotherRelation(mother, child) && !mother.Children.Contains(child) && GetParent(Sex.Female, child) == null; }
private void AddPartner(IGeneticTreeNode node, IGeneticTreeNode to) { var generation = GetSomeonesGeneration(to); AddToGeneration(generation, node, to); }