Exemple #1
0
        private void CheckValidChildrenStatus(XmlNode node)
        {
            if (Comment.Length == 0)
            {
                Comment = FamilyTree.GetNotes(node);
            }
            if (Comment.IndexOf("ignore", StringComparison.OrdinalIgnoreCase) >= 0)
            {
                this.FactErrorLevel = FactError.IGNORE;
                return;
            }
            bool success = false;
            int  total, alive, dead;

            total = alive = dead = 0;
            Match matcher = regexChildren1.Match(Comment);

            if (matcher.Success)
            {
                success = true;
                int.TryParse(matcher.Groups[1].ToString(), out total);
                int.TryParse(matcher.Groups[2].ToString(), out alive);
                int.TryParse(matcher.Groups[4].ToString(), out dead);
            }
            else
            {
                matcher = regexChildren2.Match(Comment);
                if (matcher.Success)
                {
                    success = true;
                    int.TryParse(matcher.Groups[1].ToString(), out total);
                    int.TryParse(matcher.Groups[3].ToString(), out alive);
                    int.TryParse(matcher.Groups[4].ToString(), out dead);
                }
            }
            if (success)
            {
                if (total == alive + dead)
                {
                    return;
                }
                this.FactErrorMessage = "Children status total doesn't equal numbers alive plus numbers dead.";
            }
            else
            {
                this.FactErrorMessage = "Children status doesn't match valid pattern Total x, Alive y, Dead z";
            }
            this.FactErrorNumber = (int)FamilyTree.Dataerror.CHILDRENSTATUS_TOTAL_MISMATCH;
            this.FactErrorLevel  = FactError.ERROR;
        }