Пример #1
0
        public GEDFile(XmlDocument Doc)
        {
            GEDFileEntry Entry;

            // Top level nodes are "Head", "Subm", "Indi", "Fam", "Sour"
            foreach (XmlNode Node in Doc.DocumentElement.ChildNodes)
            {
                Entry = null;

                switch (Node.Name.ToUpper())
                {
                case "HEAD":
                    Entry = new GEDFileEntryHead();
                    break;

                case "SUBM":
                    Entry = new GEDFileEntrySubm();
                    break;

                case "INDI":
                    Entry = new GEDFileEntryIndi();
                    break;

                case "FAM":
                    Entry = new GEDFileEntryFam();
                    break;

                case "SOUR":
                    Entry = new GEDFileEntrySour();
                    break;

                default:

                    frmGEDXmlEditor.Log("Node type not recognised: " + Node.Name);
                    break;
                }
                if (Entry != null)
                {
                    Entry.Node = Node;
                    Entries.Add(Entry);
                }
            }

            // Now, for each family, cross-reference individuals
            foreach (GEDFileEntry FEntry in Entries)
            {
                if (FEntry.ListType() == "FAM")
                {
                    ((GEDFileEntryFam)FEntry).ResolveXrefs();
                }
            }
        }
Пример #2
0
        public GEDFileEntry NewEntry(string Type, XmlDocument Doc)
        {
            GEDFileEntry Entry   = null;
            String       sIDCode = "";

            switch (Type)
            {
            case "HEAD":
                Entry   = new GEDFileEntryHead();
                sIDCode = "X";
                break;

            case "SUBM":
                Entry   = new GEDFileEntrySubm();
                sIDCode = "SUB";
                break;

            case "INDI":
                Entry   = new GEDFileEntryIndi();
                sIDCode = "I";
                break;

            case "FAM":
                Entry   = new GEDFileEntryFam();
                sIDCode = "F";
                break;

            case "SOUR":
                Entry   = new GEDFileEntrySour();
                sIDCode = "S";
                break;

            default:
                frmGEDXmlEditor.Log("Node type not recognised: " + Type);
                break;
            }
            if (Entry != null)
            {
                XmlNode Node;
                Node = Doc.CreateElement(Type);
                // Everything will fall apart if we create an element with no ID
                GEDXMLUtilites.SetAttribute("ID", GetNextID(sIDCode), Node);
                Doc.DocumentElement.AppendChild(Node);
                Entry.Node = Node;
                Entries.Add(Entry);
            }

            return(Entry);
        }