Example #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="GedcomMultimediaRecord"/> class.
        /// </summary>
        /// <param name="database">The database to associate with this record.</param>
        public GedcomMultimediaRecord(GedcomDatabase database)
            : this()
        {
            Database = database;
            Level    = 0;

            XRefID = database.GenerateXref("OBJE");
            database.Add(XRefID, this);
        }
Example #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="GedcomNoteRecord"/> class.
        /// </summary>
        /// <param name="database">The database to associate with this record.</param>
        public GedcomNoteRecord(GedcomDatabase database)
            : this()
        {
            Level    = 0;
            Database = database;
            XRefID   = database.GenerateXref("NOTE");
            Text     = string.Empty;

            database.Add(XRefID, this);
        }
Example #3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="GedcomSubmitterRecord"/> class.
        /// </summary>
        /// <param name="database">The database to associate with this record.</param>
        public GedcomSubmitterRecord(GedcomDatabase database)
            : this()
        {
            Database = database;

            Level  = 0;
            XRefID = database.GenerateXref("S");

            database.Add(XRefID, this);
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="GedcomRepositoryRecord"/> class.
        /// </summary>
        /// <param name="database">The database to associate with this record.</param>
        public GedcomRepositoryRecord(GedcomDatabase database)
            : this()
        {
            Database = database;
            Level    = 0;

            Name = "New Repository";

            XRefID = database.GenerateXref("REPO");
            database.Add(XRefID, this);
        }
Example #5
0
        /// <summary>
        /// Initializes a new instance of the <see cref="GedcomFamilyRecord" /> class.
        /// </summary>
        /// <param name="database">The database to associate with this record.</param>
        /// <param name="indi1">The first individual.</param>
        /// <param name="indi2">The second individual.</param>
        public GedcomFamilyRecord(GedcomDatabase database, GedcomIndividualRecord indi1, GedcomIndividualRecord indi2)
            : this()
        {
            Level    = 0;
            Database = database;
            XRefID   = database.GenerateXref("FAM");

            if (indi1 != null)
            {
                GedcomFamilyLink link = new GedcomFamilyLink();
                link.Database   = database;
                link.Family     = XRefID;
                link.Individual = indi1.XRefID;
                indi1.SpouseIn.Add(link);

                if (indi2 != null)
                {
                    link            = new GedcomFamilyLink();
                    link.Database   = database;
                    link.Family     = XRefID;
                    link.Individual = indi2.XRefID;
                    indi2.SpouseIn.Add(link);
                }

                switch (indi1.Sex)
                {
                case GedcomSex.Female:
                    Wife = indi1.XRefID;
                    if (indi2 != null)
                    {
                        Husband = indi2.XRefID;
                    }

                    break;

                default:
                    // got to put some where if not male or female,
                    // go with same as male
                    Husband = indi1.XRefID;
                    if (indi2 != null)
                    {
                        Wife = indi2.XRefID;
                    }

                    break;
                }
            }

            database.Add(XRefID, this);
        }
        /// <summary>
        /// Determines whether the specified <see cref="object" />, is equal (in contents, not structure) to this instance.
        /// </summary>
        /// <param name="gedcomDb">The <see cref="object" /> to compare with this instance.</param>
        /// <returns>
        ///   <c>true</c> if the specified <see cref="object" /> is equal to this instance; otherwise, <c>false</c>.
        /// </returns>
        public bool Equals(GedcomDatabase gedcomDb)
        {
            if (gedcomDb == null)
            {
                return(false);
            }

            if (!Equals(Header, gedcomDb.Header))
            {
                return(false);
            }

            if (!GedcomGenericListComparer.CompareGedcomRecordLists(Individuals, gedcomDb.Individuals))
            {
                return(false);
            }

            return(true);
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="GedcomSourceRecord"/> class.
        /// </summary>
        /// <param name="database">The database to associate with this record.</param>
        public GedcomSourceRecord(GedcomDatabase database)
            : this()
        {
            Database = database;
            Level    = 0;

            Title = "New Source";

            // default to filer being current user
#if __MonoCS__
            // bug in mono code, doesn't correctly get the real name, need to strip off , chars
            FiledBy = UnixUserInfo.GetRealUser().RealName.Trim(new char[] { ',' });
#endif

            if (string.IsNullOrEmpty(FiledBy))
            {
                FiledBy = Environment.UserName;
            }

            XRefID = database.GenerateXref("SOURCE");
            database.Add(XRefID, this);
        }
        /// <summary>
        /// Combines the given database with this one.
        /// This is literally what it says, no duplicate removal is performed
        /// combine will not take place if there are duplicate xrefs.
        /// </summary>
        /// <param name="database">
        /// A <see cref="GedcomDatabase"/>
        /// </param>
        /// <returns>
        /// A <see cref="bool"/>
        /// </returns>
        public virtual bool Combine(GedcomDatabase database)
        {
            // check the databases can be combined, i.e. unique xrefs
            bool canCombine = true;

            foreach (GedcomRecord record in database.Table.Values)
            {
                if (Contains(record.XRefID))
                {
                    canCombine = false;
                    break;
                }
            }

            if (canCombine)
            {
                foreach (GedcomRecord record in database.Table.Values)
                {
                    Add(record.XRefID, record);
                }
            }

            return(canCombine);
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="GedcomDate"/> class.
 /// </summary>
 /// <param name="database">The database to associate the date with.</param>
 public GedcomDate(GedcomDatabase database)
     : this()
 {
     this.Database = database;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="GedcomIndividualMatchTest"/> class.
 /// </summary>
 public GedcomIndividualMatchTest()
 {
     gedcomDb = new GedcomDatabase();
 }
Example #11
0
        /// <summary>
        /// Parses a string for a GEDCOM format date.
        /// </summary>
        /// <param name="str">The string to parse.</param>
        /// <param name="database">The database to associate the result of the parsing with.</param>
        /// <returns>The parsed age or a null if the date is not recognised.</returns>
        public static GedcomAge Parse(string str, GedcomDatabase database)
        {
            GedcomAge age = null;

            if (string.Compare(str, "INFANT", true) == 0)
            {
                age          = new GedcomAge();
                age.Database = database;
                age.Equality = -1;
                age.Years    = 1;
            }
            else if (string.Compare(str, "CHILD", true) == 0)
            {
                age          = new GedcomAge();
                age.Database = database;
                age.Equality = -1;
                age.Years    = 8;
            }
            else if (string.Compare(str, "STILLBORN", true) == 0)
            {
                age          = new GedcomAge();
                age.Database = database;
                age.Equality = 0;
                age.Years    = 0;
                age.Months   = 0;
                age.Days     = 0;
            }
            else
            {
                int equality = 0;
                int off      = 0;
                if (str[0] == '<')
                {
                    equality = -1;
                    off      = 1;
                }
                else if (str[0] == '>')
                {
                    equality = 1;
                    off      = 1;
                }

                int  val   = -1;
                bool isAge = true;
                int  year  = -1;
                int  month = -1;
                int  day   = -1;
                while (isAge && (off < str.Length))
                {
                    char c = str[off];

                    if (!char.IsWhiteSpace(c))
                    {
                        bool isDigit = char.IsDigit(c);

                        if (val == -1 && !isDigit)
                        {
                            isAge = false;
                        }
                        else if (isDigit)
                        {
                            int thisVal = val = c - '0';
                            if (val == -1)
                            {
                                val = thisVal;
                            }
                            else
                            {
                                val *= 10;
                                val += thisVal;
                            }
                        }
                        else if (c == 'Y' || c == 'y')
                        {
                            if (year != -1)
                            {
                                isAge = false;
                            }
                            else
                            {
                                year = val;
                                val  = -1;
                            }
                        }
                        else if (c == 'M' || c == 'm')
                        {
                            if (month != -1)
                            {
                                isAge = false;
                            }
                            else
                            {
                                month = val;
                                val   = -1;
                            }
                        }
                        else if (c == 'D' || c == 'd')
                        {
                            if (day != -1)
                            {
                                isAge = false;
                            }
                            else
                            {
                                day = val;
                                val = -1;
                            }
                        }
                        else
                        {
                            isAge = false;
                        }
                    }

                    off++;
                }

                isAge &= year != -1 || month != -1 || day != -1;

                if (isAge)
                {
                    age          = new GedcomAge();
                    age.Database = database;
                    age.Equality = equality;
                    age.Years    = year;
                    age.Months   = month;
                    age.Days     = day;
                }
            }

            return(age);
        }