Beispiel #1
0
 public void Import(Encyclopedia enc)
 {
     if (enc == null)
     {
         return;
     }
     foreach (EncyclopediaEntry entry in enc.Entries)
     {
         EncyclopediaEntry encyclopediaEntry = this.FindEntry(entry.ID);
         if (encyclopediaEntry != null)
         {
             this.Entries.Remove(encyclopediaEntry);
         }
         this.Entries.Add(entry);
     }
     foreach (EncyclopediaGroup group in enc.Groups)
     {
         EncyclopediaGroup encyclopediaGroup = this.FindGroup(group.ID);
         if (encyclopediaGroup != null)
         {
             this.Groups.Remove(encyclopediaGroup);
         }
         this.Groups.Add(group);
     }
     foreach (EncyclopediaLink link in enc.Links)
     {
         EncyclopediaLink encyclopediaLink = this.FindLink(link.EntryIDs[0], link.EntryIDs[1]);
         if (encyclopediaLink != null)
         {
             this.Links.Remove(encyclopediaLink);
         }
         this.Links.Add(link);
     }
 }
        public EncyclopediaLink Copy()
        {
            EncyclopediaLink encyclopediaLink = new EncyclopediaLink();

            foreach (Guid fID in this.fIDs)
            {
                encyclopediaLink.EntryIDs.Add(fID);
            }
            return(encyclopediaLink);
        }
Beispiel #3
0
        /// <summary>
        /// Creates a copy of the link.
        /// </summary>
        /// <returns>Returns the copy.</returns>
        public EncyclopediaLink Copy()
        {
            EncyclopediaLink link = new EncyclopediaLink();

            foreach (Guid id in fIDs)
            {
                link.EntryIDs.Add(id);
            }

            return(link);
        }
Beispiel #4
0
        /// <summary>
        /// Imports the data from another encyclopedia into this one.
        /// </summary>
        /// <param name="enc">The encyclopedia to import from.</param>
        public void Import(Encyclopedia enc)
        {
            if (enc == null)
            {
                return;
            }

            foreach (EncyclopediaEntry entry in enc.Entries)
            {
                // Remove any previous entry
                EncyclopediaEntry ee = FindEntry(entry.ID);
                if (ee != null)
                {
                    Entries.Remove(ee);
                }

                Entries.Add(entry);
            }

            foreach (EncyclopediaGroup group in enc.Groups)
            {
                // Remove any previous group
                EncyclopediaGroup eg = FindGroup(group.ID);
                if (eg != null)
                {
                    Groups.Remove(eg);
                }

                Groups.Add(group);
            }

            foreach (EncyclopediaLink link in enc.Links)
            {
                // Remove any previous link
                EncyclopediaLink el = FindLink(link.EntryIDs[0], link.EntryIDs[1]);
                if (el != null)
                {
                    Links.Remove(el);
                }

                Links.Add(link);
            }
        }
Beispiel #5
0
        public EncyclopediaLink FindLink(Guid entry_id_1, Guid entry_id_2)
        {
            EncyclopediaLink encyclopediaLink;

            List <EncyclopediaLink> .Enumerator enumerator = this.fLinks.GetEnumerator();
            try
            {
                while (enumerator.MoveNext())
                {
                    EncyclopediaLink current = enumerator.Current;
                    if (!current.EntryIDs.Contains(entry_id_1) || !current.EntryIDs.Contains(entry_id_2))
                    {
                        continue;
                    }
                    encyclopediaLink = current;
                    return(encyclopediaLink);
                }
                return(null);
            }
            finally
            {
                ((IDisposable)enumerator).Dispose();
            }
        }