Пример #1
0
        public override void MoveTo(GDMRecord targetRecord, bool clearDest)
        {
            GDMSourceRecord targetSource = targetRecord as GDMSourceRecord;

            if (targetSource == null)
            {
                throw new ArgumentException(@"Argument is null or wrong type", "targetRecord");
            }

            GDMLines titl = new GDMLines();
            GDMLines orig = new GDMLines();
            GDMLines publ = new GDMLines();
            GDMLines text = new GDMLines();

            titl.Text = (targetSource.Title.Lines.Text + "\n" + Title.Lines.Text).Trim();
            orig.Text = (targetSource.Originator.Lines.Text + "\n" + Originator.Lines.Text).Trim();
            publ.Text = (targetSource.Publication.Lines.Text + "\n" + Publication.Lines.Text).Trim();
            text.Text = (targetSource.Text.Lines.Text + "\n" + Text.Lines.Text).Trim();

            base.MoveTo(targetRecord, clearDest);

            targetSource.Title.Lines.Assign(titl);
            targetSource.Originator.Lines.Assign(orig);
            targetSource.Publication.Lines.Assign(publ);
            targetSource.Text.Lines.Assign(text);

            while (fRepositoryCitations.Count > 0)
            {
                GDMRepositoryCitation obj = fRepositoryCitations.Extract(0);
                obj.ResetOwner(targetSource);
                targetSource.RepositoryCitations.Add(obj);
            }
        }
Пример #2
0
        public GDMSourceCitation(GDMObject owner) : base(owner)
        {
            SetName(GEDCOMTagType.SOUR);

            fCertaintyAssessment = -1;
            fDescription         = new GDMLines();
            fPage = string.Empty;
        }
Пример #3
0
        public void Assign(GDMLines source)
        {
            if (source == null)
            {
                return;
            }

            Clear();
            AddRange(source);
        }
Пример #4
0
        public GDMSourceCitation()
        {
            SetName(GEDCOMTagType.SOUR);

            fCertaintyAssessment = -1;
            fDescription         = new GDMLines();
            fPage = string.Empty;

            fData = new GDMSourceCitationData();
            fText = new GDMTextTag((int)GEDCOMTagType.TEXT);
        }
Пример #5
0
        public void Test_SetAddress()
        {
            var vals = new string[] {
                "Address Line 1",
                "Address Line 2"
            };
            GDMLines   value    = new GDMLines(vals);
            GDMAddress instance = new GDMAddress(null);

            instance.Lines.AddRange(value);
            Assert.AreEqual(value.Text, instance.Lines.Text);
        }
Пример #6
0
        public GDMAddress()
        {
            SetName(GEDCOMTagType.ADDR);

            fLines             = new GDMLines();
            fAddressLine1      = string.Empty;
            fAddressLine2      = string.Empty;
            fAddressLine3      = string.Empty;
            fAddressCity       = string.Empty;
            fAddressState      = string.Empty;
            fAddressPostalCode = string.Empty;
            fAddressCountry    = string.Empty;

            fPhoneList = new GDMList <GDMTag>();
            fEmailList = new GDMList <GDMTag>();
            fFaxList   = new GDMList <GDMTag>();
            fWWWList   = new GDMList <GDMTag>();
        }
Пример #7
0
        public void Test_Common()
        {
            string[] list = new string[] { "The", "string", "list", "test" };

            var strList0 = new GDMLines();

            strList0.Text = "The string list test";
            Assert.AreEqual("The string list test", strList0.Text);

            GDMLines strList = new GDMLines(list);

            Assert.AreEqual("The", strList[0]);
            Assert.AreEqual("string", strList[1]);
            Assert.AreEqual("list", strList[2]);
            Assert.AreEqual("test", strList[3]);

            Assert.AreEqual(0, strList.IndexOf("The"));
            Assert.AreEqual(1, strList.IndexOf("string"));
            Assert.AreEqual(2, strList.IndexOf("list"));
            Assert.AreEqual(3, strList.IndexOf("test"));
            Assert.AreEqual(-1, strList.IndexOf("abrakadabra"));

            Assert.AreEqual("The\r\nstring\r\nlist\r\ntest", strList.Text);

            var strList1 = new GDMLines("The\r\nstring\r\nlist\r\ntest");

            Assert.AreEqual("The", strList1[0]);
            Assert.AreEqual("string", strList1[1]);
            Assert.AreEqual("list", strList1[2]);
            Assert.AreEqual("test", strList1[3]);

            GDMLines strList2 = new GDMLines();

            strList2.Assign(null);
            strList2.Assign(strList);
            Assert.AreEqual("The", strList2[0]);
            Assert.AreEqual("string", strList2[1]);
            Assert.AreEqual("list", strList2[2]);
            Assert.AreEqual("test", strList2[3]);
            strList2.Clear();

            GDMLines otherList = null;

            Assert.Throws(typeof(ArgumentNullException), () => { strList2.AddRange(otherList); });

            strList2.AddRange(strList);
            Assert.AreEqual("The", strList2[0]);
            Assert.AreEqual("string", strList2[1]);
            Assert.AreEqual("list", strList2[2]);
            Assert.AreEqual("test", strList2[3]);
            Assert.Throws(typeof(ArgumentOutOfRangeException), () => { strList2.RemoveAt(-1); });

            Assert.Throws(typeof(ArgumentOutOfRangeException), () => { object item = strList2[-1]; });
            Assert.Throws(typeof(ArgumentOutOfRangeException), () => { strList2[-1] = null; });

            string[] listVals = strList.ToArray();
            Assert.AreEqual("The", listVals[0]);
            Assert.AreEqual("string", listVals[1]);
            Assert.AreEqual("list", listVals[2]);
            Assert.AreEqual("test", listVals[3]);

            strList[2] = "string2";
            Assert.AreEqual("string2", strList[2]);

            strList.Insert(0, "insert test");
            Assert.AreEqual("insert test", strList[0]);
            Assert.Throws(typeof(ArgumentOutOfRangeException), () => { strList.Insert(-1, "insert test2"); }); // List index out of bounds

            strList.Clear();
            Assert.IsTrue(strList.IsEmpty());

            string[] strArr = null;
            Assert.Throws(typeof(ArgumentNullException), () => { strList.AddRange(strArr); });
        }
Пример #8
0
        public void Test_Common()
        {
            using (GDMIndividualAttribute customEvent = new GDMIndividualAttribute()) {
                Assert.IsNotNull(customEvent);

                Assert.IsNotNull(customEvent.Address);

                customEvent.Date.ParseString("28 DEC 1990");
                string dateTest = "28.12.1990";
                Assert.AreEqual(TestUtils.ParseDT(dateTest), customEvent.Date.GetDateTime());
                Assert.AreEqual(1990, customEvent.GetChronologicalYear());

                Assert.AreEqual(TestUtils.ParseDT(dateTest), customEvent.Date.Date);
                customEvent.Place.ParseString("Ivanovo");
                Assert.AreEqual("Ivanovo", customEvent.Place.StringValue);

                Assert.IsNotNull(customEvent.Place);

                customEvent.Agency = "test agency";
                Assert.AreEqual("test agency", customEvent.Agency);

                customEvent.Classification = "test type";
                Assert.AreEqual("test type", customEvent.Classification);

                customEvent.Cause = "test cause";
                Assert.AreEqual("test cause", customEvent.Cause);

                customEvent.ReligiousAffilation = "test aff";
                Assert.AreEqual("test aff", customEvent.ReligiousAffilation);

                customEvent.Restriction = GDMRestriction.rnLocked;
                Assert.AreEqual(GDMRestriction.rnLocked, customEvent.Restriction);


                GDMLines strs = new GDMLines("test");
                customEvent.PhysicalDescription = strs;
                Assert.AreEqual(strs.Text, customEvent.PhysicalDescription.Text);

                customEvent.Address.AddEmailAddress("email");
                Assert.AreEqual("email", customEvent.Address.EmailAddresses[0].StringValue);
            }

            using (GDMIndividualEvent customEvent = new GDMIndividualEvent()) {
                Assert.IsNotNull(customEvent);

                // stream test
                customEvent.SetName(GEDCOMTagName.BIRT);
                customEvent.Date.ParseString("20 SEP 1970");
                customEvent.Place.StringValue   = "test place";
                customEvent.Agency              = "Agency";
                customEvent.Classification      = "custom";
                customEvent.ReligiousAffilation = "rel_aff";
                customEvent.Cause = "Cause";
                customEvent.Address.AddressLine1 = "adr1";
                customEvent.Restriction          = GDMRestriction.rnConfidential;

                var note = new GDMNotes();
                note.Lines.Text = "event notes";
                customEvent.Notes.Add(note);

                var sourCit = new GDMSourceCitation();
                sourCit.Description.Text = "event sour desc";
                customEvent.SourceCitations.Add(sourCit);

                var mmLink = new GDMMultimediaLink();
                mmLink.Title = "event media title";
                customEvent.MultimediaLinks.Add(mmLink);

                using (GDMIndividualEvent copyEvent = new GDMIndividualEvent()) {
                    Assert.IsNotNull(copyEvent);
                    copyEvent.Assign(customEvent);

                    var iRec = new GDMIndividualRecord(null);
                    iRec.Events.Add(copyEvent);
                    string buf1 = TestUtils.GetTagStreamText(iRec, 0);
                    Assert.AreEqual("0 INDI\r\n" +
                                    "1 SEX U\r\n" +
                                    "1 BIRT\r\n" +
                                    "2 TYPE custom\r\n" +
                                    "2 DATE 20 SEP 1970\r\n" +
                                    "2 PLAC test place\r\n" +
                                    "2 ADDR\r\n" +
                                    "3 ADR1 adr1\r\n" +
                                    "2 CAUS Cause\r\n" +
                                    "2 AGNC Agency\r\n" +
                                    "2 RELI rel_aff\r\n" +
                                    "2 RESN confidential\r\n" +
                                    "2 NOTE event notes\r\n" +
                                    "2 SOUR event sour desc\r\n" +
                                    "2 OBJE\r\n" +
                                    "3 TITL event media title\r\n", buf1);
                }

                customEvent.Address.AddEmailAddress("email");
                Assert.AreEqual("email", customEvent.Address.EmailAddresses[0].StringValue);
            }

            using (GDMFamilyEvent customEvent = new GDMFamilyEvent()) {
                Assert.IsNotNull(customEvent);

                customEvent.Address.AddEmailAddress("email");
                Assert.AreEqual("email", customEvent.Address.EmailAddresses[0].StringValue);
            }
        }
Пример #9
0
        public GDMNoteRecord(GDMTree tree) : base(tree)
        {
            SetName(GEDCOMTagType.NOTE);

            fLines = new GDMLines();
        }
Пример #10
0
 public GDMTextTag(GDMObject owner) : base(owner)
 {
     fLines = new GDMLines();
 }
Пример #11
0
        public GDMNotes(GDMObject owner) : base(owner)
        {
            SetName(GEDCOMTagType.NOTE);

            fLines = new GDMLines();
        }
Пример #12
0
 public GDMTextTag()
 {
     fLines = new GDMLines();
 }
Пример #13
0
        public GDMNotes()
        {
            SetName(GEDCOMTagType.NOTE);

            fLines = new GDMLines();
        }