diff --git a/Gedcomx.Model.Test/AgentTest.cs b/Gedcomx.Model.Test/AgentTest.cs index 1f0a1c1..9079e59 100644 --- a/Gedcomx.Model.Test/AgentTest.cs +++ b/Gedcomx.Model.Test/AgentTest.cs @@ -31,8 +31,11 @@ public void AgentObjectInitialization() { var sut = new Agent { + // ExtensibleData Id = "A-1", + // HypermediaEnabledData Links = { new Link(), { "rel", new Uri("https://www.familysearch.org/platform/collections/tree") }, { "rel", "template" } }, + // Agent Accounts = { new OnlineAccount() }, Addresses = { new Address() }, Emails = { "example@example.org" }, @@ -77,20 +80,7 @@ private static void VerifyXmlSerialization(Agent sut) stream.Seek(0, SeekOrigin.Begin); var result = new StreamReader(stream).ReadToEnd(); - Assert.That(result, Does.Contain(" + /// Test calss for + /// + [TestFixture] + public class FactTest + { + [Test] + public void FactEmpty() + { + var sut = new Fact(); + + VerifyXmlSerialization(sut); + VerifyJsonSerialization(sut); + } + + [Test] + public void FactFilled() + { + var sut = new Fact + { + // ExtensibleData + Id = "F-1", + // Conclusion + KnownConfidence = ConfidenceLevel.Medium, + SortKey = "sort key", + Lang = "lang", + Attribution = new Attribution(), + Sources = { new SourceReference(), new SourceDescription() { Id = "S-1" } }, + Analysis = new ResourceReference(), + Notes = { new Note() }, + // Fact + Primary = true, + KnownType = FactType.Adoption, + Date = new DateInfo(), + Place = new PlaceReference(), + Value = "value", + Qualifiers = { new Qualifier() }, + Fields = { new Field() } + }; + + VerifyXmlSerialization(sut); + VerifyJsonSerialization(sut); + } + + private static void VerifyXmlSerialization(Fact sut) + { + var serializer = new XmlSerializer(typeof(Fact)); + using var stream = new MemoryStream(); + serializer.Serialize(stream, sut); + + stream.Seek(0, SeekOrigin.Begin); + var result = new StreamReader(stream).ReadToEnd(); + result.ShouldContain(sut); + } + + private static void VerifyJsonSerialization(Fact sut) + { + JsonSerializerSettings jsonSettings = new() + { + NullValueHandling = NullValueHandling.Ignore + }; + + Assert.DoesNotThrow(() => JsonConvert.DeserializeObject(JsonConvert.SerializeObject(sut, jsonSettings), jsonSettings)); + } + } +} diff --git a/Gedcomx.Model.Test/GedcomxTest.cs b/Gedcomx.Model.Test/GedcomxTest.cs index 0c0bace..717fd6e 100644 --- a/Gedcomx.Model.Test/GedcomxTest.cs +++ b/Gedcomx.Model.Test/GedcomxTest.cs @@ -56,10 +56,12 @@ public void EmmaBocockExampleTest() Created = DateTime.Parse("1843-07-27"), Repository = repository }; - Fact birth = new Fact() - .SetType(FactType.Birth) - .SetDate(new DateInfo().SetOriginal("23 June 1843")) - .SetPlace(new PlaceReference().SetOriginal("Broadfield Bar, Abbeydale Road, Ecclesall-Bierlow, York, England, United Kingdom")); + Fact birth = new() + { + KnownType = FactType.Birth, + Date = new DateInfo().SetOriginal("23 June 1843"), + Place = new PlaceReference().SetOriginal("Broadfield Bar, Abbeydale Road, Ecclesall-Bierlow, York, England, United Kingdom") + }; Person emma = (Person)new Person().SetName("Emma Bocock").SetGender(GenderType.Female).SetFact(birth).SetExtracted(true).SetSource(sourceDescription).SetId("P-1"); Person father = (Person)new Person().SetName("William Bocock").SetFact(new Fact().SetType(FactType.Occupation).SetValue("Toll Collector")).SetExtracted(true).SetSource(sourceDescription).SetId("P-2"); Person mother = (Person)new Person().SetName("Sarah Bocock formerly Brough").SetExtracted(true).SetSource(sourceDescription).SetId("P-3"); @@ -148,22 +150,28 @@ public void SamuelHamExampleTest() }; //the marriage fact. - Fact marriage = new Fact() - .SetType(FactType.Marriage) - .SetDate(new DateInfo().SetOriginal("3 November 1828").SetFormal("+1828-11-03")) - .SetPlace(new PlaceReference().SetOriginal("Wilton St George, Wilton, Somerset, England")); + Fact marriage = new() + { + KnownType = FactType.Marriage, + Date = new DateInfo().SetOriginal("3 November 1828").SetFormal("+1828-11-03"), + Place = new PlaceReference().SetOriginal("Wilton St George, Wilton, Somerset, England") + }; //the groom's residence. - Fact samsResidence = new Fact() - .SetType(FactType.Residence) - .SetDate(new DateInfo().SetOriginal("3 November 1828").SetFormal("+1828-11-03")) - .SetPlace(new PlaceReference().SetOriginal("parish of Honiton, Devon, England")); + Fact samsResidence = new() + { + KnownType = FactType.Residence, + Date = new DateInfo().SetOriginal("3 November 1828").SetFormal("+1828-11-03"), + Place = new PlaceReference().SetOriginal("parish of Honiton, Devon, England") + }; //the groom's residence. - Fact lizsResidence = new Fact() - .SetType(FactType.Residence) - .SetDate(new DateInfo().SetOriginal("3 November 1828").SetFormal("+1828-11-03")) - .SetPlace(new PlaceReference().SetOriginal("parish of Wilton, Somerset, England")); + Fact lizsResidence = new() + { + KnownType = FactType.Residence, + Date = new DateInfo().SetOriginal("3 November 1828").SetFormal("+1828-11-03"), + Place = new PlaceReference().SetOriginal("parish of Wilton, Somerset, England") + }; //the groom Person sam = (Person)new Person().SetName("Samuel Ham").SetGender(GenderType.Male).SetFact(samsResidence).SetExtracted(true).SetSource(transcriptionDescription).SetId("P-1"); @@ -568,20 +576,26 @@ public void WongAloiauExampleTest() }; //the birth. - Fact birth = new Fact() - .SetType(FactType.Birth) - .SetDate(new DateInfo().SetOriginal("former Qing 1848 year 11th month 22nd day 23-1 hour").SetFormal("+1848-11-22")) - .SetPlace(new PlaceReference().SetOriginal("Pun Sha Village, See Dai Doo, Chung Shan, Guangdong, China")); + Fact birth = new() + { + KnownType = FactType.Birth, + Date = new DateInfo().SetOriginal("former Qing 1848 year 11th month 22nd day 23-1 hour").SetFormal("+1848-11-22"), + Place = new PlaceReference().SetOriginal("Pun Sha Village, See Dai Doo, Chung Shan, Guangdong, China") + }; //the death. - Fact death = new Fact() - .SetType(FactType.Death) - .SetDate(new DateInfo().SetOriginal("Republic of China year 1920 year 7th mo. 12th day 11-13 hour").SetFormal("+1920-08-03")); + Fact death = new() + { + KnownType = FactType.Death, + Date = new DateInfo().SetOriginal("Republic of China year 1920 year 7th mo. 12th day 11-13 hour").SetFormal("+1920-08-03") + }; //the burial. - Fact burial = new Fact() - .SetType(FactType.Burial) - .SetPlace(new PlaceReference().SetOriginal("Lin Yee Chung Cemetery, Honolulu, Oahu, Hawaii")); + Fact burial = new() + { + KnownType = FactType.Burial, + Place = new PlaceReference().SetOriginal("Lin Yee Chung Cemetery, Honolulu, Oahu, Hawaii") + }; //the principal person Person aloiau = (Person)new Person().SetName("WONG Aloiau").SetGender(GenderType.Male).SetFact(birth).SetFact(death).SetFact(burial).SetExtracted(true).SetSource(translationDescription).SetId("P-1"); @@ -711,31 +725,23 @@ private static Person CreateGeorge(PlaceDescription birthPlace, PlaceDescription Person person = new(); person.SetGender(new Gender(GenderType.Male)); - Fact fact = new(); - fact.SetId("123"); - fact.SetType(FactType.Birth); - - fact.SetDate(new DateInfo()); - fact.Date.SetOriginal("February 22, 1732"); - fact.Date.SetFormal("+1732-02-22"); - - fact.SetPlace(new PlaceReference()); - fact.Place.SetOriginal(birthPlace.Names[0].Value.ToLower()); - fact.Place.DescriptionRef = "#" + birthPlace.Id; + Fact fact = new() + { + Id = "123", + KnownType = FactType.Birth, + Date = new DateInfo().SetOriginal("February 22, 1732").SetFormal("+1732-02-22"), + Place = new PlaceReference().SetOriginal(birthPlace.Names[0].Value.ToLower()).SetDescription(birthPlace) + }; person.AddFact(fact); - fact = new Fact(); - fact.SetId("456"); - fact.SetType(FactType.Death); - - fact.SetDate(new DateInfo()); - fact.Date.SetOriginal("December 14, 1799"); - fact.Date.SetFormal("+1799-12-14T22:00:00"); - - fact.SetPlace(new PlaceReference()); - fact.Place.SetOriginal(deathPlace.Names[0].Value.ToLower()); - fact.Place.DescriptionRef = "#" + deathPlace.Id; + fact = new() + { + Id = "456", + KnownType = FactType.Death, + Date = new DateInfo().SetOriginal("December 14, 1799").SetFormal("+1799-12-14T22:00:00"), + Place = new PlaceReference().SetOriginal(deathPlace.Names[0].Value.ToLower()).SetDescription(deathPlace) + }; person.AddFact(fact); @@ -768,31 +774,23 @@ private static Person CreateMartha(PlaceDescription birthPlace, PlaceDescription Person person = new(); person.SetGender(new Gender(GenderType.Male)); - Fact fact = new(); - fact.SetId("321"); - fact.SetType(FactType.Birth); - - fact.SetDate(new DateInfo()); - fact.Date.SetOriginal("June 2, 1731"); - fact.Date.SetFormal("+1731-06-02"); - - fact.SetPlace(new PlaceReference()); - fact.Place.SetOriginal(birthPlace.Names[0].Value.ToLower()); - fact.Place.DescriptionRef = "#" + birthPlace.Id; + Fact fact = new() + { + Id = "321", + KnownType = FactType.Birth, + Date = new DateInfo().SetOriginal("June 2, 1731").SetFormal("+1731-06-02"), + Place = new PlaceReference().SetOriginal(birthPlace.Names[0].Value.ToLower()).SetDescription(birthPlace) + }; person.AddFact(fact); - fact = new Fact(); - fact.SetId("654"); - fact.SetType(FactType.Death); - - fact.SetDate(new DateInfo()); - fact.Date.SetOriginal("May 22, 1802"); - fact.Date.SetFormal("+1802-05-22"); - - fact.SetPlace(new PlaceReference()); - fact.Place.SetOriginal(deathPlace.Names[0].Value.ToLower()); - fact.Place.DescriptionRef = "#" + deathPlace.Id; + fact = new() + { + Id = "654", + KnownType = FactType.Death, + Date = new DateInfo().SetOriginal("May 22, 1802").SetFormal("+1802-05-22"), + Place = new PlaceReference().SetOriginal(deathPlace.Names[0].Value.ToLower()).SetDescription(deathPlace) + }; person.AddFact(fact); diff --git a/Gedcomx.Model.Test/OnlineAccountTest.cs b/Gedcomx.Model.Test/OnlineAccountTest.cs index cf2e417..6cae222 100644 --- a/Gedcomx.Model.Test/OnlineAccountTest.cs +++ b/Gedcomx.Model.Test/OnlineAccountTest.cs @@ -1,5 +1,7 @@ using System.Xml.Serialization; +using Gx.Agent; + using Newtonsoft.Json; using NUnit.Framework; @@ -7,7 +9,7 @@ namespace Gedcomx.Model.Test { /// - /// Test calss for + /// Test calss for /// [TestFixture] public class OnlineAccountTest @@ -15,7 +17,7 @@ public class OnlineAccountTest [Test] public void OnlineAccountEmpty() { - var sut = new Gx.Agent.OnlineAccount(); + var sut = new OnlineAccount(); VerifyXmlSerialization(sut); VerifyJsonSerialization(sut); @@ -24,9 +26,11 @@ public void OnlineAccountEmpty() [Test] public void OnlineAccountFilled() { - var sut = new Gx.Agent.OnlineAccount + var sut = new OnlineAccount { + // ExtensibleData Id = "O-1", + // OnlineAccount AccountName = "Peter Pan", ServiceHomepage = new Gx.Common.ResourceReference() }; @@ -35,30 +39,25 @@ public void OnlineAccountFilled() VerifyJsonSerialization(sut); } - private static void VerifyXmlSerialization(Gx.Agent.OnlineAccount sut) + private static void VerifyXmlSerialization(OnlineAccount sut) { - var serializer = new XmlSerializer(typeof(Gx.Agent.OnlineAccount)); + var serializer = new XmlSerializer(typeof(OnlineAccount)); using var stream = new MemoryStream(); serializer.Serialize(stream, sut); stream.Seek(0, SeekOrigin.Begin); var result = new StreamReader(stream).ReadToEnd(); - Assert.That(result, Does.Contain(" JsonConvert.DeserializeObject(JsonConvert.SerializeObject(sut, jsonSettings), jsonSettings)); + Assert.DoesNotThrow(() => JsonConvert.DeserializeObject(JsonConvert.SerializeObject(sut, jsonSettings), jsonSettings)); } } } diff --git a/Gedcomx.Model.Test/SourceDescriptionTest.cs b/Gedcomx.Model.Test/SourceDescriptionTest.cs index c50045e..8de8cdf 100644 --- a/Gedcomx.Model.Test/SourceDescriptionTest.cs +++ b/Gedcomx.Model.Test/SourceDescriptionTest.cs @@ -33,8 +33,11 @@ public void AgentObjectInitialization() { var sut = new SourceDescription { + // ExtensibleData Id = "A-1", + // HypermediaEnabledData Links = { new Link(), { "rel", new Uri("https://www.familysearch.org/platform/collections/tree") }, { "rel", "template" } }, + // SourceDescription About = "about text", Lang = "language", MediaType = "type of media", @@ -67,26 +70,7 @@ private static void VerifyXmlSerialization(SourceDescription sut) stream.Seek(0, SeekOrigin.Begin); var result = new StreamReader(stream).ReadToEnd(); - Assert.That(result, Does.Contain(""), Is.EqualTo(sut.AnyTitles())); - Assert.That(result.Contains(""), Is.EqualTo(sourceDescription.AnyTitles())); + Assert.That(result.Contains("Enunciate. // using System; -using System.Collections.Generic; +using System.Linq; using Gedcomx.Model.Util; using Gx.Common; -using Gx.Model; using Gx.Source; using Gx.Types; @@ -123,13 +122,18 @@ public System.Collections.Generic.List Sources { get { - return this._sources; + return this._sources ?? (_sources = new System.Collections.Generic.List()); } set { this._sources = value; } } + public bool ShouldSerializeSources() => AnySources(); + public bool AnySources() + { + return _sources?.Any() ?? false; + } /// /// A reference to the analysis document explaining the analysis that went into this conclusion. /// @@ -155,13 +159,18 @@ public System.Collections.Generic.List Notes { get { - return this._notes; + return this._notes ?? (_notes = new System.Collections.Generic.List()); } set { this._notes = value; } } + public bool ShouldSerializeNotes() => AnyNotes(); + public bool AnyNotes() + { + return _notes?.Any() ?? false; + } protected internal override void Embed(ExtensibleData conclusion) { @@ -172,13 +181,11 @@ protected internal override void Embed(ExtensibleData conclusion) this._analysis = this._analysis == null ? value._analysis : this._analysis; if (value._notes != null) { - this._notes = this._notes == null ? new List() : this._notes; - this._notes.AddRange(value._notes); + this.Notes.AddRange(value._notes); } if (value._sources != null) { - this._sources = this._sources == null ? new List() : this._sources; - this._sources.AddRange(value._sources); + this.Sources.AddRange(value._sources); } base.Embed(conclusion); } @@ -219,17 +226,6 @@ public Conclusion SetConfidence(ConfidenceLevel confidence) return this; } - /** - * Build up this conclusion with a source reference. - * - * @param source The source description being referenced. - * @return this. - */ - public Conclusion SetSource(SourceDescription source) - { - return SetSource(new SourceReference().SetDescription(source)); - } - /** * Build up this conclusion with a source reference. * @@ -238,7 +234,10 @@ public Conclusion SetSource(SourceDescription source) */ public Conclusion SetSource(SourceReference sourceReference) { - AddSource(sourceReference); + if (sourceReference != null) + { + Sources.Add(sourceReference); + } return this; } @@ -250,7 +249,10 @@ public Conclusion SetSource(SourceReference sourceReference) */ public Conclusion SetNote(Note note) { - AddNote(note); + if (note != null) + { + _notes.Add(note); + } return this; } @@ -289,39 +291,5 @@ public Conclusion SetSortKey(String sortKey) SortKey = sortKey; return this; } - - /** - * Add a source reference. - * - * @param source The source reference to be added. - */ - public void AddSource(SourceReference source) - { - if (source != null) - { - if (_sources == null) - { - _sources = new List(); - } - _sources.Add(source); - } - } - - /** - * Add a note. - * - * @param note The note to be added. - */ - public void AddNote(Note note) - { - if (note != null) - { - if (_notes == null) - { - _notes = new List(); - } - _notes.Add(note); - } - } } } diff --git a/Gedcomx.Model/Fact.cs b/Gedcomx.Model/Fact.cs index 6ec0fcc..0505a03 100644 --- a/Gedcomx.Model/Fact.cs +++ b/Gedcomx.Model/Fact.cs @@ -1,15 +1,17 @@ -using Gedcomx.Model.Rt; -using Gedcomx.Model.Util; -using Gx.Common; -using Gx.Records; -using Gx.Types; -// +// // // // Generated by Enunciate. // using System; -using System.Collections.Generic; +using System.Linq; + +using Gedcomx.Model.Rt; +using Gedcomx.Model.Util; + +using Gx.Common; +using Gx.Records; +using Gx.Types; namespace Gx.Conclusion { @@ -44,12 +46,12 @@ public Fact(FactType factType, String value) } public Fact(FactType factType, String date, String place) - :this(factType, new DateInfo().SetOriginal(date), new PlaceReference().SetOriginal(place), null) + : this(factType, new DateInfo().SetOriginal(date), new PlaceReference().SetOriginal(place), null) { } public Fact(FactType factType, DateInfo date, PlaceReference place) - :this(factType, date, place, null) + : this(factType, date, place, null) { } @@ -70,12 +72,12 @@ public bool Primary { get { - return this._primary.GetValueOrDefault(); + return _primary.GetValueOrDefault(); } set { - this._primary = value; - this._primarySpecified = true; + _primary = value; + _primarySpecified = true; } } @@ -89,11 +91,11 @@ public bool PrimarySpecified { get { - return this._primarySpecified; + return _primarySpecified; } set { - this._primarySpecified = value; + _primarySpecified = value; } } @@ -106,11 +108,11 @@ public string Type { get { - return this._type; + return _type; } set { - this._type = value; + _type = value; } } @@ -123,11 +125,11 @@ public Gx.Types.FactType KnownType { get { - return XmlQNameEnumUtil.GetEnumValue(this._type); + return XmlQNameEnumUtil.GetEnumValue(_type); } set { - this._type = XmlQNameEnumUtil.GetNameValue(value); + _type = XmlQNameEnumUtil.GetNameValue(value); } } /// @@ -139,11 +141,11 @@ public Gx.Conclusion.DateInfo Date { get { - return this._date; + return _date; } set { - this._date = value; + _date = value; } } /// @@ -155,11 +157,11 @@ public Gx.Conclusion.PlaceReference Place { get { - return this._place; + return _place; } set { - this._place = value; + _place = value; } } /// @@ -171,11 +173,11 @@ public string Value { get { - return this._value; + return _value; } set { - this._value = value; + _value = value; } } /// @@ -187,13 +189,18 @@ public System.Collections.Generic.List Qualifiers { get { - return this._qualifiers; + return _qualifiers ?? (_qualifiers = new System.Collections.Generic.List()); } set { - this._qualifiers = value; + _qualifiers = value; } } + public bool ShouldSerializeQualifiers() => AnyQualifiers(); + public bool AnyQualifiers() + { + return _qualifiers?.Any() ?? false; + } /// /// The references to the record fields being used as evidence. /// @@ -203,13 +210,18 @@ public System.Collections.Generic.List Fields { get { - return this._fields; + return _fields ?? (_fields = new System.Collections.Generic.List()); } set { - this._fields = value; + _fields = value; } } + public bool ShouldSerializeFields() => AnyFields(); + public bool AnyFields() + { + return _fields?.Any() ?? false; + } /** * Accept a visitor. @@ -301,7 +313,7 @@ public Fact SetValue(String value) */ public Fact SetQualifier(Qualifier qualifier) { - AddQualifier(qualifier); + Qualifiers.Add(qualifier); return this; } @@ -312,40 +324,12 @@ public Fact SetQualifier(Qualifier qualifier) * @return this. */ public Fact SetField(Field field) - { - AddField(field); - return this; - } - - /** - * Add a qualifier. - * - * @param qualifier The qualifier. - */ - public void AddQualifier(Qualifier qualifier) - { - if (this._qualifiers == null) - { - this._qualifiers = new List(); - } - this._qualifiers.Add(qualifier); - } - - /** - * Add a reference to the record field values being used as evidence. - * - * @param field The field to be added. - */ - public void AddField(Field field) { if (field != null) { - if (_fields == null) - { - _fields = new List(); - } - _fields.Add(field); + Fields.Add(field); } + return this; } } } diff --git a/Gedcomx.Model/SourceReference.cs b/Gedcomx.Model/SourceReference.cs index b963d75..ebe7f0b 100644 --- a/Gedcomx.Model/SourceReference.cs +++ b/Gedcomx.Model/SourceReference.cs @@ -1,7 +1,4 @@ -using Gedcomx.Model.Rt; -using Gx.Common; -using Newtonsoft.Json; -// +// // // // Generated by Enunciate. @@ -9,6 +6,12 @@ using System; using System.Collections.Generic; +using Gedcomx.Model.Rt; + +using Gx.Common; + +using Newtonsoft.Json; + namespace Gx.Source { @@ -28,6 +31,16 @@ public partial class SourceReference : Gx.Links.HypermediaEnabledData, IAttribut private Gx.Common.Attribution _attribution; private System.Collections.Generic.List _qualifiers; private System.Collections.Generic.List _tags; + + /// + /// Build up this source reference with a reference. + /// + /// The source description being referenced. + public static implicit operator SourceReference(SourceDescription description) + { + return new SourceReference().SetDescription(description); + } + /// /// A reference to a description of the source being referenced. /// @@ -103,12 +116,12 @@ public void Accept(IGedcomxModelVisitor visitor) visitor.VisitSourceReference(this); } - /** - * Build up this source reference with a description reference. - * - * @param description The description. - * @return this. - */ + /// + /// Build up this source reference with a reference. + /// + /// The source description being referenced. + /// this. + /// If the description Id is null. public SourceReference SetDescription(SourceDescription description) { if (description.Id == null) diff --git a/Gedcomx.Rs.Api.Test/ParentsAndChildrenTest.cs b/Gedcomx.Rs.Api.Test/ParentsAndChildrenTest.cs index 6b51bef..0b250d5 100644 --- a/Gedcomx.Rs.Api.Test/ParentsAndChildrenTest.cs +++ b/Gedcomx.Rs.Api.Test/ParentsAndChildrenTest.cs @@ -133,7 +133,7 @@ public void TestReadChildAndParentsRelationshipSourceReferences() var son = tree.AddPerson(TestBacking.GetCreateMalePerson()); cleanup.Add(son); var temp = TestBacking.GetCreateChildAndParentsRelationship(father, mother, son); - temp.AddSource(TestBacking.GetPersonSourceReference()); + temp.SetSource(TestBacking.GetPersonSourceReference()); var relationship = (ChildAndParentsRelationshipState)tree.AddChildAndParentsRelationship(temp).Get(); cleanup.Add(relationship); var state = relationship.LoadSourceReferences(); @@ -223,7 +223,7 @@ public void TestDeleteChildAndParentsRelationshipSourceReference() var son = tree.AddPerson(TestBacking.GetCreateMalePerson()); cleanup.Add(son); var temp = TestBacking.GetCreateChildAndParentsRelationship(father, mother, son); - temp.AddSource(TestBacking.GetPersonSourceReference()); + temp.SetSource(TestBacking.GetPersonSourceReference()); var relationship = (ChildAndParentsRelationshipState)tree.AddChildAndParentsRelationship(temp).Get(); cleanup.Add(relationship);