Exemplo n.º 1
0
        public void TestParsing(string input, int level, string xrefId, string tag, string lineValue)
        {
            var line = new GEDComLine(input);

            Assert.Equal(level, line.Level);
            Assert.Equal(xrefId, line.XrefId);
            Assert.Equal(tag, line.Tag);
            Assert.Equal(lineValue, line.LineValue);
        }
Exemplo n.º 2
0
        private Family ParseFamily(Queue <GEDComLine> queue)
        {
            GEDComLine line = queue.Dequeue();
            Family     f    = new Family
            {
                XrefId = line.XrefId
            };

            while (queue.Count > 0 && queue.Peek().Level >= 1)
            {
                GEDComLine subinformation = queue.Dequeue();

                switch (subinformation.Tag)
                {
                case "HUSB":
                    f.HusbandXrefId = subinformation.LineValue;
                    break;

                case "WIFE":
                    f.WifeXrefId = subinformation.LineValue;
                    break;

                case "MARR":
                    while (queue.Count > 0 && queue.Peek().Level >= 2)
                    {
                        GEDComLine level2Information = queue.Dequeue();
                        switch (level2Information.Tag)
                        {
                        case "PLAC":
                            f.PlaceOfWedding = level2Information.LineValue;
                            break;

                        default:
                            _logger.LogDebug($"Unknown Marriage information type: {level2Information.Tag}");
                            break;
                        }
                    }

                    break;

                case "CHIL":
                    if (f.ChildrenXrefIds == null)
                    {
                        f.ChildrenXrefIds = new List <string>();
                    }
                    f.ChildrenXrefIds.Add(subinformation.LineValue);
                    break;

                default:
                    _logger.LogDebug($"Unknown Family information type: {subinformation.Tag}");
                    break;
                }
            }

            return(f);
        }
Exemplo n.º 3
0
        private void ParseLevel0(Queue <GEDComLine> queue)
        {
            while (queue.Count > 0)
            {
                GEDComLine line = queue.Peek();
                if (line.Level == 0)
                {
                    switch (line.Tag)
                    {
                    case "INDI":
                        Individual i = ParseIndividual(queue);
                        _gedModel.Individuals.Add(i.XrefId, i);
                        break;

                    case "FAM":
                        Family f = ParseFamily(queue);
                        _gedModel.Families.Add(f.XrefId, f);
                        break;

                    default:
                        queue.Dequeue();
                        _logger.LogDebug($"Unknown level 0 type: {line}");
                        while (queue.Count > 0 && queue.Peek().Level > 0)
                        {
                            queue.Dequeue();
                        }
                        break;
                    }
                }
                else
                {
                    queue.Dequeue();
                    _logger.LogInformation($"Expecting level 0 type: {line}");
                }
            }
        }
Exemplo n.º 4
0
        private Individual ParseIndividual(Queue <GEDComLine> queue)
        {
            GEDComLine line = queue.Dequeue();
            Individual i    = new Individual
            {
                XrefId = line.XrefId
            };

            while (queue.Count > 0 && queue.Peek().Level >= 1)
            {
                GEDComLine subinformation = queue.Dequeue();

                switch (subinformation.Tag)
                {
                case "NAME":
                    i.Name = subinformation.LineValue;
                    break;

                case "SEX":
                    i.Sex = subinformation.LineValue;
                    break;

                case "_UID":
                    i.Uid = subinformation.LineValue;
                    break;

                case "BIRT":
                    while (queue.Count > 0 && queue.Peek().Level >= 2)
                    {
                        GEDComLine level2Information = queue.Dequeue();
                        switch (level2Information.Tag)
                        {
                        case "PLAC":
                            i.PlaceOfBirth = level2Information.LineValue;
                            break;

                        default:
                            _logger.LogDebug($"Unknown Birth information type: {level2Information.Tag}");
                            break;
                        }
                    }

                    break;

                case "DEAT":
                    while (queue.Count > 0 && queue.Peek().Level >= 2)
                    {
                        GEDComLine level2Information = queue.Dequeue();
                        switch (level2Information.Tag)
                        {
                        case "PLAC":
                            i.PlaceOfDeath = level2Information.LineValue;
                            break;

                        default:
                            _logger.LogDebug($"Unknown Death information type: {level2Information.Tag}");
                            break;
                        }
                    }

                    break;

                default:
                    _logger.LogDebug($"Unknown Individual information type: {subinformation.Tag}");
                    break;
                }
            }

            return(i);
        }