public Family(XmlNode node, IProgress <string> outputText) : this(string.Empty) { if (node != null) { XmlNode eHusband = node.SelectSingleNode("HUSB"); XmlNode eWife = node.SelectSingleNode("WIFE"); FamilyID = node.Attributes["ID"].Value; string husbandID = eHusband?.Attributes["REF"]?.Value; string wifeID = eWife?.Attributes["REF"]?.Value; Husband = ft.GetIndividual(husbandID); Wife = ft.GetIndividual(wifeID); if (Husband != null && Wife != null) { Wife.MarriedName = Husband.Surname; } if (Husband != null) { Husband.FamiliesAsSpouse.Add(this); } if (Wife != null) { Wife.FamiliesAsSpouse.Add(this); } // now iterate through child elements of eChildren // finding all individuals XmlNodeList list = node.SelectNodes("CHIL"); foreach (XmlNode n in list) { if (n.Attributes["REF"] != null) { Individual child = ft.GetIndividual(n.Attributes["REF"].Value); if (child != null) { XmlNode fatherNode = n.SelectSingleNode("_FREL"); XmlNode motherNode = n.SelectSingleNode("_MREL"); var father = ParentalRelationship.GetRelationshipType(fatherNode); var mother = ParentalRelationship.GetRelationshipType(motherNode); Children.Add(child); var parent = new ParentalRelationship(this, father, mother); child.FamiliesAsChild.Add(parent); AddParentAndChildrenFacts(child, Husband, father); AddParentAndChildrenFacts(child, Wife, mother); } else { outputText.Report($"Child not found in family: {FamilyRef}\n"); } } else { outputText.Report($"Child without a reference found in family: {FamilyRef}\n"); } } AddFacts(node, Fact.ANNULMENT, outputText); AddFacts(node, Fact.DIVORCE, outputText); AddFacts(node, Fact.DIVORCE_FILED, outputText); AddFacts(node, Fact.ENGAGEMENT, outputText); AddFacts(node, Fact.MARRIAGE, outputText); AddFacts(node, Fact.MARRIAGE_BANN, outputText); AddFacts(node, Fact.MARR_CONTRACT, outputText); AddFacts(node, Fact.MARR_LICENSE, outputText); AddFacts(node, Fact.MARR_SETTLEMENT, outputText); AddFacts(node, Fact.SEPARATION, outputText); AddFacts(node, Fact.CENSUS, outputText); AddFacts(node, Fact.CUSTOM_EVENT, outputText); AddFacts(node, Fact.CUSTOM_FACT, outputText); AddFacts(node, Fact.REFERENCE, outputText); AddFacts(node, Fact.SEALED_TO_SPOUSE, outputText); AddFacts(node, Fact.UNKNOWN, outputText); //TODO: need to think about family facts having AGE tags in GEDCOM if (HasGoodChildrenStatus) { CheckChildrenStatusCounts(); } if (MarriageDate.IsKnown && !MarriageDate.Overlaps(FactDate.SAME_SEX_MARRIAGE)) // check for wrongly set gender only if pre-dates same sex marriages { if (Husband != null && !Husband.IsMale) { Husband.QuestionGender(this, true); } if (Wife != null && Wife.IsMale) { Wife.QuestionGender(this, false); } } Children.ToList().Sort(new BirthDateComparer()); } }
public Family(XmlNode node) : this(string.Empty) { if (node != null) { XmlNode eHusband = node.SelectSingleNode("HUSB"); XmlNode eWife = node.SelectSingleNode("WIFE"); this.FamilyID = node.Attributes["ID"].Value; string husbandID = eHusband == null || eHusband.Attributes["REF"] == null ? null : eHusband.Attributes["REF"].Value; string wifeID = eWife == null || eWife.Attributes["REF"] == null ? null : eWife.Attributes["REF"].Value; FamilyTree ft = FamilyTree.Instance; this.Husband = ft.GetIndividual(husbandID); this.Wife = ft.GetIndividual(wifeID); if (Husband != null && Wife != null) { Wife.MarriedName = Husband.Surname; } if (Husband != null) { Husband.FamiliesAsParent.Add(this); } if (Wife != null) { Wife.FamiliesAsParent.Add(this); } // now iterate through child elements of eChildren // finding all individuals XmlNodeList list = node.SelectNodes("CHIL"); foreach (XmlNode n in list) { if (n.Attributes["REF"] != null) { Individual child = ft.GetIndividual(n.Attributes["REF"].Value); if (child != null) { XmlNode fatherNode = node.SelectSingleNode("CHIL/_FREL"); XmlNode motherNode = node.SelectSingleNode("CHIL/_MREL"); ParentalRelationship.ParentalRelationshipType father = ParentalRelationship.GetRelationshipType(fatherNode); ParentalRelationship.ParentalRelationshipType mother = ParentalRelationship.GetRelationshipType(motherNode); Children.Add(child); ParentalRelationship parent = new ParentalRelationship(this, father, mother); child.FamiliesAsChild.Add(parent); AddParentAndChildrenFacts(child, Husband, father); AddParentAndChildrenFacts(child, Wife, mother); } else { ft.XmlErrorBox.AppendText("Child not found in family :" + FamilyRef + "\n"); } } else { ft.XmlErrorBox.AppendText("Child without a reference found in family : " + FamilyRef + "\n"); } } AddFacts(node, Fact.ANNULMENT); AddFacts(node, Fact.DIVORCE); AddFacts(node, Fact.DIVORCE_FILED); AddFacts(node, Fact.ENGAGEMENT); AddFacts(node, Fact.MARRIAGE); AddFacts(node, Fact.MARRIAGE_BANN); AddFacts(node, Fact.MARR_CONTRACT); AddFacts(node, Fact.MARR_LICENSE); AddFacts(node, Fact.MARR_SETTLEMENT); AddFacts(node, Fact.SEPARATION); AddFacts(node, Fact.CENSUS); AddFacts(node, Fact.CUSTOM_EVENT); AddFacts(node, Fact.CUSTOM_FACT); AddFacts(node, Fact.REFERENCE); AddFacts(node, Fact.UNKNOWN); //TODO: need to think about family facts having AGE tags in GEDCOM if (HasGoodChildrenStatus) { CheckChildrenStatusCounts(); } } }