/// <summary>
 /// Visits the specified <see cref="Gx.Gedcomx"/> entity.
 /// </summary>
 /// <param name="gx">The <see cref="Gx.Gedcomx"/> entity to visit.</param>
 public override void VisitGedcomx(Gx.Gedcomx gx)
 {
     if (gx.Id != null)
     {
         this.dictionary.Add(gx.Id, gx);
     }
     base.VisitGedcomx(gx);
 }
 /// <summary>
 /// Initializes an id dictionary for the specified data set.
 /// </summary>
 /// <param name='gx'>
 /// The data set.
 /// </param>
 public GedcomxIdDictionary(Gedcomx gx)
 {
     VisitGedcomx(gx);
 }
Exemple #3
0
        public virtual void Embed(Gedcomx gedcomx)
        {
            List<Link> links = gedcomx.Links;
            if (links != null)
            {
                foreach (Link link in links)
                {
                    bool found = false;
                    if (link.Rel != null)
                    {
                        if (Links != null)
                        {
                            foreach (Link target in Links)
                            {
                                if (link.Rel.Equals(target.Rel))
                                {
                                    found = true;
                                    break;
                                }
                            }
                        }
                    }

                    if (!found)
                    {
                        AddLink(link);
                    }
                }
            }

            List<Person> persons = gedcomx.Persons;
            if (persons != null)
            {
                foreach (Person person in persons)
                {
                    bool found = false;
                    if (person.Id != null)
                    {
                        if (Persons != null)
                        {
                            foreach (Person target in Persons)
                            {
                                if (person.Id.Equals(target.Id))
                                {
                                    target.Embed(person);
                                    found = true;
                                    break;
                                }
                            }
                        }
                    }

                    if (!found)
                    {
                        AddPerson(person);
                    }
                }
            }

            List<Relationship> relationships = gedcomx.Relationships;
            if (relationships != null)
            {
                foreach (Relationship relationship in relationships)
                {
                    bool found = false;
                    if (relationship.Id != null)
                    {
                        if (Relationships != null)
                        {
                            foreach (Relationship target in Relationships)
                            {
                                if (relationship.Id.Equals(target.Id))
                                {
                                    target.Embed(relationship);
                                    found = true;
                                    break;
                                }
                            }
                        }
                    }

                    if (!found)
                    {
                        AddRelationship(relationship);
                    }
                }
            }

            List<SourceDescription> sourceDescriptions = gedcomx.SourceDescriptions;
            if (sourceDescriptions != null)
            {
                foreach (SourceDescription sourceDescription in sourceDescriptions)
                {
                    bool found = false;
                    if (sourceDescription.Id != null)
                    {
                        if (SourceDescriptions != null)
                        {
                            foreach (SourceDescription target in SourceDescriptions)
                            {
                                if (sourceDescription.Id.Equals(target.Id))
                                {
                                    target.Embed(sourceDescription);
                                    found = true;
                                    break;
                                }
                            }
                        }
                    }

                    if (!found)
                    {
                        AddSourceDescription(sourceDescription);
                    }
                }
            }

            List<Gx.Agent.Agent> agents = gedcomx.Agents;
            if (agents != null)
            {
                foreach (Gx.Agent.Agent agent in agents)
                {
                    bool found = false;
                    if (agent.Id != null)
                    {
                        if (Agents != null)
                        {
                            foreach (Gx.Agent.Agent target in Agents)
                            {
                                if (agent.Id.Equals(target.Id))
                                {
                                    target.Embed(agent);
                                    found = true;
                                    break;
                                }
                            }
                        }
                    }

                    if (!found)
                    {
                        AddAgent(agent);
                    }
                }
            }

            List<Event> events = gedcomx.Events;
            if (events != null)
            {
                foreach (Event @event in events)
                {
                    bool found = false;
                    if (@event.Id != null)
                    {
                        if (Events != null)
                        {
                            foreach (Event target in Events)
                            {
                                if (@event.Id.Equals(target.Id))
                                {
                                    target.Embed(@event);
                                    found = true;
                                    break;
                                }
                            }
                        }
                    }

                    if (!found)
                    {
                        AddEvent(@event);
                    }
                }
            }

            List<PlaceDescription> placeDescriptions = gedcomx.Places;
            if (placeDescriptions != null)
            {
                foreach (PlaceDescription placeDescription in placeDescriptions)
                {
                    bool found = false;
                    if (placeDescription.Id != null)
                    {
                        if (Places != null)
                        {
                            foreach (PlaceDescription target in Places)
                            {
                                if (placeDescription.Id.Equals(target.Id))
                                {
                                    target.Embed(placeDescription);
                                    found = true;
                                    break;
                                }
                            }
                        }
                    }

                    if (!found)
                    {
                        AddPlace(placeDescription);
                    }
                }
            }

            List<Document> documents = gedcomx.Documents;
            if (documents != null)
            {
                foreach (Document document in documents)
                {
                    bool found = false;
                    if (document.Id != null)
                    {
                        if (Documents != null)
                        {
                            foreach (Document target in Documents)
                            {
                                if (document.Id.Equals(target.Id))
                                {
                                    target.Embed(document);
                                    found = true;
                                    break;
                                }
                            }
                        }
                    }

                    if (!found)
                    {
                        AddDocument(document);
                    }
                }
            }

            List<Collection> collections = gedcomx.Collections;
            if (collections != null)
            {
                foreach (Collection collection in collections)
                {
                    bool found = false;
                    if (collection.Id != null)
                    {
                        if (Collections != null)
                        {
                            foreach (Collection target in Collections)
                            {
                                if (collection.Id.Equals(target.Id))
                                {
                                    target.Embed(collection);
                                    found = true;
                                    break;
                                }
                            }
                        }
                    }

                    if (!found)
                    {
                        AddCollection(collection);
                    }
                }
            }

            List<Field> fields = gedcomx.Fields;
            if (fields != null)
            {
                foreach (Field field in fields)
                {
                    bool found = false;
                    if (field.Id != null)
                    {
                        if (Fields != null)
                        {
                            foreach (Field target in Fields)
                            {
                                if (field.Id.Equals(target.Id))
                                {
                                    found = true;
                                    break;
                                }
                            }
                        }
                    }

                    if (!found)
                    {
                        AddField(field);
                    }
                }
            }

            List<RecordDescriptor> recordDescriptors = gedcomx.RecordDescriptors;
            if (recordDescriptors != null)
            {
                foreach (RecordDescriptor recordDescriptor in recordDescriptors)
                {
                    bool found = false;
                    if (recordDescriptor.Id != null)
                    {
                        if (RecordDescriptors != null)
                        {
                            foreach (RecordDescriptor target in RecordDescriptors)
                            {
                                if (recordDescriptor.Id.Equals(target.Id))
                                {
                                    target.Embed(recordDescriptor);
                                    found = true;
                                    break;
                                }
                            }
                        }
                    }

                    if (!found)
                    {
                        AddRecordDescriptor(recordDescriptor);
                    }
                }
            }
        }
Exemple #4
0
        public virtual void Embed(Gedcomx gedcomx)
        {
            List <Link> links = gedcomx.Links;

            if (links != null)
            {
                foreach (Link link in links)
                {
                    bool found = false;
                    if (link.Rel != null)
                    {
                        if (Links != null)
                        {
                            foreach (Link target in Links)
                            {
                                if (link.Rel.Equals(target.Rel))
                                {
                                    found = true;
                                    break;
                                }
                            }
                        }
                    }

                    if (!found)
                    {
                        AddLink(link);
                    }
                }
            }

            List <Person> persons = gedcomx.Persons;

            if (persons != null)
            {
                foreach (Person person in persons)
                {
                    bool found = false;
                    if (person.Id != null)
                    {
                        if (Persons != null)
                        {
                            foreach (Person target in Persons)
                            {
                                if (person.Id.Equals(target.Id))
                                {
                                    target.Embed(person);
                                    found = true;
                                    break;
                                }
                            }
                        }
                    }

                    if (!found)
                    {
                        AddPerson(person);
                    }
                }
            }

            List <Relationship> relationships = gedcomx.Relationships;

            if (relationships != null)
            {
                foreach (Relationship relationship in relationships)
                {
                    bool found = false;
                    if (relationship.Id != null)
                    {
                        if (Relationships != null)
                        {
                            foreach (Relationship target in Relationships)
                            {
                                if (relationship.Id.Equals(target.Id))
                                {
                                    target.Embed(relationship);
                                    found = true;
                                    break;
                                }
                            }
                        }
                    }

                    if (!found)
                    {
                        AddRelationship(relationship);
                    }
                }
            }

            List <SourceDescription> sourceDescriptions = gedcomx.SourceDescriptions;

            if (sourceDescriptions != null)
            {
                foreach (SourceDescription sourceDescription in sourceDescriptions)
                {
                    bool found = false;
                    if (sourceDescription.Id != null)
                    {
                        if (SourceDescriptions != null)
                        {
                            foreach (SourceDescription target in SourceDescriptions)
                            {
                                if (sourceDescription.Id.Equals(target.Id))
                                {
                                    target.Embed(sourceDescription);
                                    found = true;
                                    break;
                                }
                            }
                        }
                    }

                    if (!found)
                    {
                        AddSourceDescription(sourceDescription);
                    }
                }
            }

            List <Gx.Agent.Agent> agents = gedcomx.Agents;

            if (agents != null)
            {
                foreach (Gx.Agent.Agent agent in agents)
                {
                    bool found = false;
                    if (agent.Id != null)
                    {
                        if (Agents != null)
                        {
                            foreach (Gx.Agent.Agent target in Agents)
                            {
                                if (agent.Id.Equals(target.Id))
                                {
                                    target.Embed(agent);
                                    found = true;
                                    break;
                                }
                            }
                        }
                    }

                    if (!found)
                    {
                        AddAgent(agent);
                    }
                }
            }

            List <Event> events = gedcomx.Events;

            if (events != null)
            {
                foreach (Event @event in events)
                {
                    bool found = false;
                    if (@event.Id != null)
                    {
                        if (Events != null)
                        {
                            foreach (Event target in Events)
                            {
                                if (@event.Id.Equals(target.Id))
                                {
                                    target.Embed(@event);
                                    found = true;
                                    break;
                                }
                            }
                        }
                    }

                    if (!found)
                    {
                        AddEvent(@event);
                    }
                }
            }

            List <PlaceDescription> placeDescriptions = gedcomx.Places;

            if (placeDescriptions != null)
            {
                foreach (PlaceDescription placeDescription in placeDescriptions)
                {
                    bool found = false;
                    if (placeDescription.Id != null)
                    {
                        if (Places != null)
                        {
                            foreach (PlaceDescription target in Places)
                            {
                                if (placeDescription.Id.Equals(target.Id))
                                {
                                    target.Embed(placeDescription);
                                    found = true;
                                    break;
                                }
                            }
                        }
                    }

                    if (!found)
                    {
                        AddPlace(placeDescription);
                    }
                }
            }

            List <Document> documents = gedcomx.Documents;

            if (documents != null)
            {
                foreach (Document document in documents)
                {
                    bool found = false;
                    if (document.Id != null)
                    {
                        if (Documents != null)
                        {
                            foreach (Document target in Documents)
                            {
                                if (document.Id.Equals(target.Id))
                                {
                                    target.Embed(document);
                                    found = true;
                                    break;
                                }
                            }
                        }
                    }

                    if (!found)
                    {
                        AddDocument(document);
                    }
                }
            }

            List <Collection> collections = gedcomx.Collections;

            if (collections != null)
            {
                foreach (Collection collection in collections)
                {
                    bool found = false;
                    if (collection.Id != null)
                    {
                        if (Collections != null)
                        {
                            foreach (Collection target in Collections)
                            {
                                if (collection.Id.Equals(target.Id))
                                {
                                    target.Embed(collection);
                                    found = true;
                                    break;
                                }
                            }
                        }
                    }

                    if (!found)
                    {
                        AddCollection(collection);
                    }
                }
            }

            List <Field> fields = gedcomx.Fields;

            if (fields != null)
            {
                foreach (Field field in fields)
                {
                    bool found = false;
                    if (field.Id != null)
                    {
                        if (Fields != null)
                        {
                            foreach (Field target in Fields)
                            {
                                if (field.Id.Equals(target.Id))
                                {
                                    found = true;
                                    break;
                                }
                            }
                        }
                    }

                    if (!found)
                    {
                        AddField(field);
                    }
                }
            }

            List <RecordDescriptor> recordDescriptors = gedcomx.RecordDescriptors;

            if (recordDescriptors != null)
            {
                foreach (RecordDescriptor recordDescriptor in recordDescriptors)
                {
                    bool found = false;
                    if (recordDescriptor.Id != null)
                    {
                        if (RecordDescriptors != null)
                        {
                            foreach (RecordDescriptor target in RecordDescriptors)
                            {
                                if (recordDescriptor.Id.Equals(target.Id))
                                {
                                    target.Embed(recordDescriptor);
                                    found = true;
                                    break;
                                }
                            }
                        }
                    }

                    if (!found)
                    {
                        AddRecordDescriptor(recordDescriptor);
                    }
                }
            }
        }
        /// <summary>
        /// Visits the <see cref="Gx.Gedcomx"/> entity.
        /// </summary>
        /// <param name="gx">The <see cref="Gx.Gedcomx"/> to visit.</param>
        public virtual void VisitGedcomx(Gedcomx gx)
        {
            this.contextStack.Push(gx);

            if (gx.Persons != null)
            {
                foreach (Person person in gx.Persons)
                {
                    if (person != null)
                    {
                        VisitPerson(person);
                    }
                }
            }

            if (gx.Relationships != null)
            {
                foreach (Relationship relationship in gx.Relationships)
                {
                    if (relationship != null)
                    {
                        VisitRelationship(relationship);
                    }
                }
            }

            if (gx.SourceDescriptions != null)
            {
                foreach (SourceDescription sourceDescription in gx.SourceDescriptions)
                {
                    if (sourceDescription != null)
                    {
                        VisitSourceDescription(sourceDescription);
                    }
                }
            }

            if (gx.Agents != null)
            {
                foreach (Gx.Agent.Agent agent in gx.Agents)
                {
                    if (agent != null)
                    {
                        VisitAgent(agent);
                    }
                }
            }

            if (gx.Events != null)
            {
                foreach (Event e in gx.Events)
                {
                    if (e != null)
                    {
                        VisitEvent(e);
                    }
                }
            }

            if (gx.Places != null)
            {
                foreach (PlaceDescription place in gx.Places)
                {
                    if (place != null)
                    {
                        VisitPlaceDescription(place);
                    }
                }
            }

            if (gx.Documents != null)
            {
                foreach (Document document in gx.Documents)
                {
                    if (document != null)
                    {
                        VisitDocument(document);
                    }
                }
            }

            if (gx.Fields != null)
            {
                foreach (Field field in gx.Fields)
                {
                    if (field != null)
                    {
                        VisitField(field);
                    }
                }
            }

            if (gx.RecordDescriptors != null)
            {
                foreach (RecordDescriptor rd in gx.RecordDescriptors)
                {
                    if (rd != null)
                    {
                        VisitRecordDescriptor(rd);
                    }
                }
            }

            if (gx.Collections != null)
            {
                foreach (Collection collection in gx.Collections)
                {
                    if (collection != null)
                    {
                        VisitCollection(collection);
                    }
                }
            }

            this.contextStack.Pop();
        }