diff --git a/FamilySearch.Api/Ft/ChildAndParentsRelationshipState.cs b/FamilySearch.Api/Ft/ChildAndParentsRelationshipState.cs index 0a14483..6f3bd52 100644 --- a/FamilySearch.Api/Ft/ChildAndParentsRelationshipState.cs +++ b/FamilySearch.Api/Ft/ChildAndParentsRelationshipState.cs @@ -1,19 +1,22 @@ -using Gx.Fs; -using Gx.Rs.Api; -using RestSharp; -using System; +using System; using System.Collections.Generic; using System.Linq; -using System.Text; -using Gx.Rs.Api.Util; using System.Net; + +using FamilySearch.Api.Util; + using Gedcomx.Model; -using Gx.Fs.Tree; -using Gx.Conclusion; + using Gx.Common; -using Gx.Source; +using Gx.Conclusion; +using Gx.Fs; +using Gx.Fs.Tree; using Gx.Links; -using FamilySearch.Api.Util; +using Gx.Rs.Api; +using Gx.Rs.Api.Util; +using Gx.Source; + +using RestSharp; namespace FamilySearch.Api.Ft { @@ -195,7 +198,7 @@ public EvidenceReference EvidenceReference get { ChildAndParentsRelationship relationship = Relationship; - return relationship == null ? null : relationship.Evidence == null ? null : relationship.Evidence.FirstOrDefault(); + return relationship == null ? null : relationship.AnyEvidence() ? null : relationship.Evidence.FirstOrDefault(); } } @@ -210,7 +213,7 @@ public SourceReference MediaReference get { ChildAndParentsRelationship relationship = Relationship; - return relationship == null ? null : relationship.Media == null ? null : relationship.Media.FirstOrDefault(); + return relationship == null ? null : relationship.AnyMedia() ? null : relationship.Media.FirstOrDefault(); } } @@ -604,14 +607,14 @@ public ChildAndParentsRelationshipState UpdateSourceReferences(SourceReference[] protected ChildAndParentsRelationshipState UpdateSourceReferences(ChildAndParentsRelationship relationship, params IStateTransitionOption[] options) { String target = GetSelfUri() + "/" + Rel.SOURCE_REFERENCES; - //Link conclusionsLink = GetLink(Rel.SOURCE_REFERENCES); - //if (conclusionsLink != null && conclusionsLink.Href != null) - //{ - // target = conclusionsLink.Href; - //} - - - FamilySearchPlatform gx = new FamilySearchPlatform(); + //Link conclusionsLink = GetLink(Rel.SOURCE_REFERENCES); + //if (conclusionsLink != null && conclusionsLink.Href != null) + //{ + // target = conclusionsLink.Href; + //} + + + FamilySearchPlatform gx = new FamilySearchPlatform(); gx.ChildAndParentsRelationships = new List() { relationship }; IRestRequest request = RequestUtil.ApplyFamilySearchConneg(CreateAuthenticatedRequest()).SetEntity(gx).Build(target, Method.POST); return ((FamilyTreeStateFactory)this.stateFactory).NewChildAndParentsRelationshipState(request, Invoke(request, options), this.Client, this.CurrentAccessToken); diff --git a/Gedcomx.Model.Test/GedcomxTest.cs b/Gedcomx.Model.Test/GedcomxTest.cs index 717fd6e..8b05d2f 100644 --- a/Gedcomx.Model.Test/GedcomxTest.cs +++ b/Gedcomx.Model.Test/GedcomxTest.cs @@ -3,7 +3,7 @@ using Gx.Agent; using Gx.Common; using Gx.Conclusion; -using Gx.Records; +using Gx.Model.Collections; using Gx.Source; using Gx.Types; @@ -62,13 +62,39 @@ public void EmmaBocockExampleTest() 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"); + Person emma = new() + { + Id = "P-1", + Names = { "Emma Bocock" }, + Gender = new Gender(GenderType.Female), + Facts = { birth }, + Extracted = true, + Sources = { sourceDescription } + }; + Person father = new() + { + Id = "P-2", + Names = { "William Bocock" }, + Facts = { new Fact() { KnownType = FactType.Occupation, Value = "Toll Collector" } }, + Extracted = true, + Sources = { sourceDescription } + }; + Person mother = new() + { + Id = "P-3", + Names = { "Sarah Bocock formerly Brough" }, + Extracted = true, + Sources = { sourceDescription } + }; Relationship fatherRelationship = new Relationship().SetType(RelationshipType.ParentChild).SetPerson1(father).SetPerson2(emma); Relationship motherRelationship = new Relationship().SetType(RelationshipType.ParentChild).SetPerson1(mother).SetPerson2(emma); Document analysis = (Document)new Document().SetText("...Jane Doe's analysis document...").SetId("D-1"); - Person emmaConclusion = (Person)new Person().SetEvidence(emma).SetAnalysis(analysis).SetId("C-1"); + Person emmaConclusion = new() + { + Id = "C-1", + Evidence = { emma }, + Analysis = analysis, + }; Gx.Gedcomx gx = new Gx.Gedcomx() .SetAgent(contributor) .SetAgent(repository) @@ -174,18 +200,56 @@ public void SamuelHamExampleTest() }; //the groom - Person sam = (Person)new Person().SetName("Samuel Ham").SetGender(GenderType.Male).SetFact(samsResidence).SetExtracted(true).SetSource(transcriptionDescription).SetId("P-1"); + Person sam = new() + { + Id = "P-1", + Names = { "Samuel Ham" }, + Facts = { samsResidence }, + Extracted = true, + Sources = { transcriptionDescription } + }; //the bride. - Person liz = (Person)new Person().SetName("Elizabeth Spiller").SetGender(GenderType.Female).SetFact(lizsResidence).SetExtracted(true).SetSource(transcriptionDescription).SetId("P-2"); + Person liz = new() + { + Id = "P-2", + Names = { "Elizabeth Spiller" }, + Facts = { lizsResidence }, + Extracted = true, + Sources = { transcriptionDescription } + }; //witnesses - Person witness1 = (Person)new Person().SetName("Jno. Pain").SetExtracted(true).SetSource(transcriptionDescription).SetId("P-3"); - Person witness2 = (Person)new Person().SetName("R.G. Halls").SetExtracted(true).SetSource(transcriptionDescription).SetId("P-4"); - Person witness3 = (Person)new Person().SetName("Peggy Hammet").SetExtracted(true).SetSource(transcriptionDescription).SetId("P-5"); + Person witness1 = new() + { + Id = "P-3", + Names = { "Jno. Pain" }, + Extracted = true, + Sources = { transcriptionDescription } + }; + Person witness2 = new() + { + Id = "P-4", + Names = { "R.G. Halls" }, + Extracted = true, + Sources = { transcriptionDescription } + }; + Person witness3 = new() + { + Id = "P-5", + Names = { "Peggy Hammet" }, + Extracted = true, + Sources = { transcriptionDescription } + }; //officiator - Person officiator = (Person)new Person().SetName("David Smith Stone").SetExtracted(true).SetSource(transcriptionDescription).SetId("P-6"); + Person officiator = new() + { + Id = "P-6", + Names = { "David Smith Stone" }, + Extracted = true, + Sources = { transcriptionDescription } + }; //the relationship. Relationship marriageRelationship = (Relationship)new Relationship().SetType(RelationshipType.Couple).SetPerson1(sam).SetPerson2(liz).SetFact(marriage).SetExtracted(true); @@ -207,7 +271,12 @@ public void SamuelHamExampleTest() Document analysis = (Document)new Document().SetText("...Jane Doe's analysis document...").SetId("D-2"); //Jane Doe's conclusions about a person. - Person samConclusion = (Person)new Person().SetEvidence(sam).SetAnalysis(analysis).SetId("C-1"); + Person samConclusion = new() + { + Id = "C-1", + Evidence = { sam }, + Analysis = analysis, + }; Gx.Gedcomx gx = new Gx.Gedcomx() .SetAgent(janeDoe) @@ -569,7 +638,7 @@ public void WongAloiauExampleTest() Id = "S-4", About = "#" + translation.Id, Titles = { "Translation of Grave Marker of WONG Aloiau, Lin Yee Chung Cemetery, Honolulu, Oahu, Hawaii" }, - Citations= { new SourceCitation().SetValue("WONG Aloiau gravestone, Lin Yee Chung Cemetery, Honolulu, Oahu, Hawaii; visited May 1975 by Jane Doe. Translation by HANYU Pinyin 王大年.") }, + Citations = { new SourceCitation().SetValue("WONG Aloiau gravestone, Lin Yee Chung Cemetery, Honolulu, Oahu, Hawaii; visited May 1975 by Jane Doe. Translation by HANYU Pinyin 王大年.") }, Attribution = translationAttribution, KnownResourceType = ResourceType.DigitalArtifact, Sources = { new SourceReference().SetDescription(transcriptionDescription) } @@ -598,10 +667,24 @@ public void WongAloiauExampleTest() }; //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"); + Person aloiau = new() + { + Id = "P-1", + Names = { "WONG Aloiau" }, + Gender = new Gender(GenderType.Male), + Facts = { birth, death, burial }, + Extracted = true, + Sources = { translationDescription } + }; //the father of the principal (with an aka name). - Person father = (Person)new Person().SetName("Lo Yau").SetName(new Name().SetType(NameType.AlsoKnownAs).SetNameForm(new NameForm().SetFullText("Young Hong Wong"))).SetExtracted(true).SetSource(translationDescription).SetId("P-2"); + Person father = new() + { + Id = "P-2", + Names = { "Lo Yau", new Name() { KnownType = NameType.AlsoKnownAs }.SetNameForm(new NameForm().SetFullText("Young Hong Wong")) }, + Extracted = true, + Sources = { translationDescription } + }; //the relationship. Relationship fatherRelationship = new Relationship().SetType(RelationshipType.ParentChild).SetPerson1(father).SetPerson2(aloiau); @@ -610,7 +693,12 @@ public void WongAloiauExampleTest() Document analysis = (Document)new Document().SetText("...Jane Doe's analysis document...").SetId("D-3"); //Jane Doe's conclusions about a person. - Person aloiauConclusion = (Person)new Person().SetEvidence(aloiau).SetAnalysis(analysis).SetId("C-1"); + Person aloiauConclusion = new() + { + Id = "C-1", + Evidence = { aloiau }, + Analysis = analysis + }; Gx.Gedcomx gx = new Gx.Gedcomx() .SetAgent(janeDoe) @@ -733,7 +821,7 @@ private static Person CreateGeorge(PlaceDescription birthPlace, PlaceDescription Place = new PlaceReference().SetOriginal(birthPlace.Names[0].Value.ToLower()).SetDescription(birthPlace) }; - person.AddFact(fact); + person.SetFact(fact); fact = new() { @@ -743,9 +831,9 @@ private static Person CreateGeorge(PlaceDescription birthPlace, PlaceDescription Place = new PlaceReference().SetOriginal(deathPlace.Names[0].Value.ToLower()).SetDescription(deathPlace) }; - person.AddFact(fact); + person.SetFact(fact); - List names = new(); + Names names = new(); Name name = new(); NameForm nameForm = new(); nameForm.SetFullText("George Washington"); @@ -782,7 +870,7 @@ private static Person CreateMartha(PlaceDescription birthPlace, PlaceDescription Place = new PlaceReference().SetOriginal(birthPlace.Names[0].Value.ToLower()).SetDescription(birthPlace) }; - person.AddFact(fact); + person.SetFact(fact); fact = new() { @@ -792,9 +880,9 @@ private static Person CreateMartha(PlaceDescription birthPlace, PlaceDescription Place = new PlaceReference().SetOriginal(deathPlace.Names[0].Value.ToLower()).SetDescription(deathPlace) }; - person.AddFact(fact); + person.SetFact(fact); - List names = new(); + Names names = new(); Name name = new(); NameForm nameForm = new(); nameForm.SetFullText("Martha Dandridge Custis"); diff --git a/Gedcomx.Model.Test/PersonTest.cs b/Gedcomx.Model.Test/PersonTest.cs new file mode 100644 index 0000000..b8fd582 --- /dev/null +++ b/Gedcomx.Model.Test/PersonTest.cs @@ -0,0 +1,90 @@ +using System.Xml.Serialization; + +using Gx.Common; +using Gx.Conclusion; +using Gx.Links; +using Gx.Records; +using Gx.Source; +using Gx.Types; + +using Newtonsoft.Json; + +using NUnit.Framework; + +namespace Gedcomx.Model.Test +{ + /// + /// Test calss for + /// + [TestFixture] + public class PersonTest + { + [Test] + public void PersonEmpty() + { + var sut = new Person(); + + VerifyXmlSerialization(sut); + VerifyJsonSerialization(sut); + } + + [Test] + public void PersonObjectInitialization() + { + var sut = new Person + { + // ExtensibleData + Id = "A-1", + // HypermediaEnabledData + Links = { new Link(), { "rel", new Uri("https://www.familysearch.org/platform/collections/tree") }, { "rel", "template" } }, + // Conclusion + KnownConfidence = ConfidenceLevel.Medium, + SortKey = "sortKey", + Lang = "lang", + Attribution = new Attribution(), + Sources = { new SourceDescription { Id = "S-1" }, new SourceReference() }, + Analysis = new ResourceReference(), + Notes = { new Note() }, + // Subject + Extracted = true, + Evidence = { new EvidenceReference() }, + Media = { new SourceReference(), new SourceDescription() { Id = "D-1" } }, + Identifiers = { new Identifier() }, + // Person + Principal = false, + Private = true, + Living = true, + Gender = new Gender(GenderType.Female), + Names = { "Emma Bocock" }, + Facts = { new Fact() }, + Fields = { new Field() }, + DisplayExtension = new DisplayProperties(), + DiscussionReferences = { new DiscussionReference() } + }; + + VerifyXmlSerialization(sut); + VerifyJsonSerialization(sut); + } + + private static void VerifyXmlSerialization(Person sut) + { + var serializer = new XmlSerializer(typeof(Person)); + 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(Person sut) + { + JsonSerializerSettings jsonSettings = new() + { + NullValueHandling = NullValueHandling.Ignore + }; + + Assert.DoesNotThrow(() => JsonConvert.DeserializeObject(JsonConvert.SerializeObject(sut, jsonSettings), jsonSettings)); + } + } +} diff --git a/Gedcomx.Model.Test/XmlAssertions.cs b/Gedcomx.Model.Test/XmlAssertions.cs index 031fee3..5e8ec73 100644 --- a/Gedcomx.Model.Test/XmlAssertions.cs +++ b/Gedcomx.Model.Test/XmlAssertions.cs @@ -27,6 +27,33 @@ public static void ShouldContain(this string result, Agent agent) result.ShouldContain(agent as HypermediaEnabledData); } + public static void ShouldContain(this string result, Person person) + { + Assert.That(result, Does.Contain(" + /// A list of . + /// + public class Names : List + { + /// + /// Add a name form to the list of name forms. + /// + /// The value. + public void Add(string value) => Add(new Name(value)); + + /// + /// Add a name form to the list of name forms. + /// + /// The value. + /// The name partsto be added. + public void Add(string value, params NamePart[] parts) => Add(new Name(value, parts)); + } +} diff --git a/Gedcomx.Model/EvidenceReference.cs b/Gedcomx.Model/EvidenceReference.cs index f1ef8d7..d4729f5 100644 --- a/Gedcomx.Model/EvidenceReference.cs +++ b/Gedcomx.Model/EvidenceReference.cs @@ -1,11 +1,14 @@ -using Gedcomx.Model.Rt; -// +// // // // Generated by Enunciate. // using System; +using Gedcomx.Model.Rt; + +using Gx.Conclusion; + namespace Gx.Common { @@ -24,6 +27,17 @@ public sealed partial class EvidenceReference : Gx.Links.HypermediaEnabledData, private string _resource; private Gx.Common.Attribution _attribution; + + public static implicit operator EvidenceReference(Person evidence) + { + if (evidence.Id == null) + { + throw new ArgumentException("Unable to add person as evidence: no id."); + } + + return new EvidenceReference("#" + evidence.Id); + } + public EvidenceReference() { } @@ -32,7 +46,7 @@ public EvidenceReference(String resource) { this.Resource = resource; } - + /// /// The resource id of the resource being referenced. /// diff --git a/Gedcomx.Model/Person.cs b/Gedcomx.Model/Person.cs index 3e4c382..b01ced6 100644 --- a/Gedcomx.Model/Person.cs +++ b/Gedcomx.Model/Person.cs @@ -5,6 +5,7 @@ // using System; using System.Collections.Generic; +using System.Linq; using Gedcomx.Model.Rt; @@ -33,11 +34,12 @@ public partial class Person : Gx.Conclusion.Subject private bool? _living; private bool _livingSpecified; private Gx.Conclusion.Gender _gender; - private System.Collections.Generic.List _names; + private Gx.Model.Collections.Names _names; private System.Collections.Generic.List _facts; private System.Collections.Generic.List _fields; private Gx.Conclusion.DisplayProperties _displayExtension; private System.Collections.Generic.List _discussionreference; + /// /// Whether this person is the "principal" person extracted from the record. /// @@ -167,17 +169,22 @@ public Gx.Conclusion.Gender Gender /// [System.Xml.Serialization.XmlElementAttribute(ElementName = "name", Namespace = "http://gedcomx.org/v1/")] [Newtonsoft.Json.JsonProperty("names")] - public System.Collections.Generic.List Names + public Gx.Model.Collections.Names Names { get { - return this._names; + return this._names ?? (_names = new Gx.Model.Collections.Names()); } set { this._names = value; } } + public bool ShouldSerializeNames() => AnyNames(); + public bool AnyNames() + { + return _names?.Any() ?? false; + } /// /// The fact conclusions for the person. /// @@ -187,13 +194,18 @@ public System.Collections.Generic.List Facts { get { - return this._facts; + return this._facts ?? (_facts = new System.Collections.Generic.List()); } set { this._facts = value; } } + public bool ShouldSerializeFacts() => AnyFacts(); + public bool AnyFacts() + { + return _facts?.Any() ?? false; + } /// /// The references to the record fields being used as evidence. /// @@ -203,13 +215,18 @@ public System.Collections.Generic.List Fields { get { - return this._fields; + return this._fields ?? (_fields = new System.Collections.Generic.List()); } set { this._fields = value; } } + public bool ShouldSerializeFields() => AnyFields(); + public bool AnyFields() + { + return _fields?.Any() ?? false; + } /// /// Display properties for the person. Display properties are not specified by GEDCOM X core, but as extension elements by GEDCOM X RS. /// @@ -235,13 +252,18 @@ public System.Collections.Generic.List Discussion { get { - return this._discussionreference; + return this._discussionreference ?? (_discussionreference = new System.Collections.Generic.List()); } set { this._discussionreference = value; } } + public bool ShouldSerializeDiscussionReferences() => AnyDiscussionReferences(); + public bool AnyDiscussionReferences() + { + return _discussionreference?.Any() ?? false; + } /// /// Combine '#' and person Id to be used with @@ -277,18 +299,15 @@ public void Embed(Person person) } if (person._names != null) { - this._names = this._names == null ? new List() : this._names; - this._names.AddRange(person._names); + this.Names.AddRange(person._names); } if (person._facts != null) { - this._facts = this._facts == null ? new List() : this._facts; - this._facts.AddRange(person._facts); + this.Facts.AddRange(person._facts); } if (person._fields != null) { - this._fields = this._fields == null ? new List() : this._fields; - this._fields.AddRange(person._fields); + this.Fields.AddRange(person._fields); } base.Embed(person); } @@ -311,7 +330,7 @@ public void Accept(IGedcomxModelVisitor visitor) */ public Subject SetPersonaReference(EvidenceReference persona) { - AddEvidence(persona); + SetEvidence(persona); return this; } @@ -356,7 +375,7 @@ public Person SetGender(Gender gender) */ public Person SetGender(GenderType gender) { - Gender = new Gender().SetType(gender); + Gender = new Gender(gender); return this; } @@ -367,7 +386,10 @@ public Person SetGender(GenderType gender) */ public Person SetName(Name name) { - AddName(name); + if (name != null) + { + Names.Add(name); + } return this; } @@ -378,8 +400,7 @@ public Person SetName(Name name) */ public Person SetName(String name) { - AddName(new Name().SetNameForm(new NameForm().SetFullText(name))); - return this; + return SetName(new Name(name)); } /** @@ -390,7 +411,10 @@ public Person SetName(String name) */ public Person SetFact(Fact fact) { - AddFact(fact); + if (fact != null) + { + Facts.Add(fact); + } return this; } @@ -412,70 +436,12 @@ public Person SetDisplayExtension(DisplayProperties display) * @return this. */ public Person SetField(Field field) - { - AddField(field); - return this; - } - - /** - * Add a name conclusion to the person. - * - * @param name The name conclusion to be added. - */ - public void AddName(Name name) - { - if (name != null) - { - if (_names == null) - { - _names = new List(); - } - _names.Add(name); - } - } - - /** - * Add a fact conclusion to the person. - * - * @param fact The fact conclusion to be added. - */ - public void AddFact(Fact fact) - { - if (fact != null) - { - if (_facts == null) - { - _facts = new List(); - } - _facts.Add(fact); - } - } - - /** - * 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); - } - } - - public Person SetEvidence(Person evidence) - { - if (evidence.Id == null) - { - throw new ArgumentException("Unable to add person as evidence: no id."); + Fields.Add(field); } - - return (Person)base.SetEvidence(new EvidenceReference("#" + evidence.Id)); + return this; } } } diff --git a/Gedcomx.Model/Rt/GedcomxModelVisitorBase.cs b/Gedcomx.Model/Rt/GedcomxModelVisitorBase.cs index 5ac50d3..21130c2 100644 --- a/Gedcomx.Model/Rt/GedcomxModelVisitorBase.cs +++ b/Gedcomx.Model/Rt/GedcomxModelVisitorBase.cs @@ -313,18 +313,18 @@ protected virtual void VisitSubject(Subject subject) { VisitConclusion(subject); - List media = subject.Media; - if (media != null) + if (subject.AnyMedia()) { + List media = subject.Media; foreach (SourceReference reference in media) { reference.Accept(this); } } - List evidence = subject.Evidence; - if (evidence != null) + if (subject.AnyEvidence()) { + List evidence = subject.Evidence; foreach (EvidenceReference evidenceReference in evidence) { evidenceReference.Accept(this); diff --git a/Gedcomx.Model/Subject.cs b/Gedcomx.Model/Subject.cs index 984b5fc..becf155 100644 --- a/Gedcomx.Model/Subject.cs +++ b/Gedcomx.Model/Subject.cs @@ -1,14 +1,17 @@ -using Gedcomx.Model.Util; -using Gx.Common; -using Gx.Source; -using Newtonsoft.Json; -// +// // // // Generated by Enunciate. // using System; -using System.Collections.Generic; +using System.Linq; + +using Gedcomx.Model.Util; + +using Gx.Common; +using Gx.Source; + +using Newtonsoft.Json; namespace Gx.Conclusion { @@ -80,13 +83,18 @@ public System.Collections.Generic.List Evidence { get { - return this._evidence; + return this._evidence ?? (_evidence = new System.Collections.Generic.List()); } set { this._evidence = value; } } + public bool ShouldSerializeEvidence() => AnyEvidence(); + public bool AnyEvidence() + { + return _evidence?.Any() ?? false; + } /// /// References to multimedia resources associated with this subject. /// @@ -96,13 +104,18 @@ public System.Collections.Generic.List Media { get { - return this._media; + return this._media ?? (_media = new System.Collections.Generic.List()); } set { this._media = value; } } + public bool ShouldSerializeMedia() => AnyMedia(); + public bool AnyMedia() + { + return _media?.Any() ?? false; + } /// /// The list of identifiers for the subject. /// @@ -113,13 +126,18 @@ public System.Collections.Generic.List Identifiers { get { - return this._identifiers; + return this._identifiers ?? (_identifiers = new System.Collections.Generic.List()); } set { this._identifiers = value; } } + public bool ShouldSerializeIdentifiers() => AnyIdentifiers(); + public bool AnyIdentifiers() + { + return _identifiers?.Any() ?? false; + } protected internal override void Embed(ExtensibleData subject) { @@ -128,40 +146,20 @@ protected internal override void Embed(ExtensibleData subject) if (value._identifiers != null) { - this._identifiers = this._identifiers == null ? new List() : this._identifiers; - this._identifiers.AddRange(value._identifiers); + this.Identifiers.AddRange(value._identifiers); } if (value._media != null) { - this._media = this._media == null ? new List() : this._media; - this._media.AddRange(value._media); + this.Media.AddRange(value._media); } if (value._evidence != null) { - this._evidence = this._evidence == null ? new List() : this._evidence; - this._evidence.AddRange(value._evidence); + this.Evidence.AddRange(value._evidence); } base.Embed(subject); } - /** - * Add an evidence reference for this subject. - * - * @param evidenceRef The evidence to be added. - */ - public void AddEvidence(EvidenceReference evidenceRef) - { - if (evidenceRef != null) - { - if (_evidence == null) - { - _evidence = new List(); - } - _evidence.Add(evidenceRef); - } - } - /** * Build up this subject with an extracted flag. * @@ -182,19 +180,22 @@ public Subject SetExtracted(Boolean extracted) */ public Subject SetIdentifier(Identifier identifier) { - AddIdentifier(identifier); + Identifiers.Add(identifier); return this; } /** - * Build up this subject with an evidence reference. + * Add an evidence reference for this subject. * * @param evidence The evidence reference. * @return this. */ public Subject SetEvidence(EvidenceReference evidence) { - AddEvidence(evidence); + if (evidence != null) + { + Evidence.Add(evidence); + } return this; } @@ -206,54 +207,11 @@ public Subject SetEvidence(EvidenceReference evidence) */ public Subject SetMedia(SourceReference media) { - AddMedia(media); - return this; - } - - /** - * Build up this subject with a media reference. - * - * @param media The media reference. - * @return this. - */ - public Subject SetMedia(SourceDescription media) - { - AddMedia(new SourceReference().SetDescription(media)); - return this; - } - - /** - * Add an identifier of the subject. - * - * @param identifier The identifier to be added. - */ - public void AddIdentifier(Identifier identifier) - { - if (identifier != null) + if (media != null) { - if (_identifiers == null) - { - _identifiers = new List(); - } - _identifiers.Add(identifier); - } - } - - /** - * Add an media reference associated with this subject. - * - * @param mediaRef The reference to the media to be added. - */ - public void AddMedia(SourceReference mediaRef) - { - if (mediaRef != null) - { - if (_media == null) - { - _media = new List(); - } - _media.Add(mediaRef); + Media.Add(media); } + return this; } } } diff --git a/Gedcomx.Rs.Api.Test/Examples/GeorgeMarthaWashingtonExampleTest.cs b/Gedcomx.Rs.Api.Test/Examples/GeorgeMarthaWashingtonExampleTest.cs index 7dc1c3b..403b4e1 100644 --- a/Gedcomx.Rs.Api.Test/Examples/GeorgeMarthaWashingtonExampleTest.cs +++ b/Gedcomx.Rs.Api.Test/Examples/GeorgeMarthaWashingtonExampleTest.cs @@ -5,6 +5,7 @@ using Gx.Agent; using Gx.Common; using Gx.Conclusion; +using Gx.Model.Collections; using Gx.Source; using Gx.Types; @@ -52,7 +53,7 @@ public void TestExample() jsonSerializer.Deserialize(jsonSerializer.Serialize(gx)); } - private PlaceDescription CreatePopesCreek() + private static PlaceDescription CreatePopesCreek() { PlaceDescription place = new PlaceDescription(); place.SetId("888"); @@ -62,7 +63,7 @@ private PlaceDescription CreatePopesCreek() return place; } - private PlaceDescription CreateMountVernon() + private static PlaceDescription CreateMountVernon() { PlaceDescription place = new PlaceDescription(); place.SetId("999"); @@ -72,7 +73,7 @@ private PlaceDescription CreateMountVernon() return place; } - private PlaceDescription CreateChestnutGrove() + private static PlaceDescription CreateChestnutGrove() { PlaceDescription place = new PlaceDescription(); place.SetId("KKK"); @@ -82,7 +83,7 @@ private PlaceDescription CreateChestnutGrove() return place; } - private Agent CreateContributor() + private static Agent CreateContributor() { Agent agent = new Agent(); agent.SetId("GGG-GGGG"); @@ -90,7 +91,7 @@ private Agent CreateContributor() return agent; } - private Person CreateGeorge(PlaceDescription birthPlace, PlaceDescription deathPlace) + private static Person CreateGeorge(PlaceDescription birthPlace, PlaceDescription deathPlace) { Person person = new Person(); person.SetGender(new Gender(GenderType.Male)); @@ -107,7 +108,7 @@ private Person CreateGeorge(PlaceDescription birthPlace, PlaceDescription deathP fact.Place.SetOriginal(birthPlace.Names[0].Value.ToLower()); fact.Place.DescriptionRef = "#" + birthPlace.Id; - person.AddFact(fact); + person.SetFact(fact); fact = new Fact(); fact.SetId("456"); @@ -121,9 +122,9 @@ private Person CreateGeorge(PlaceDescription birthPlace, PlaceDescription deathP fact.Place.SetOriginal(deathPlace.Names[0].Value.ToLower()); fact.Place.DescriptionRef = "#" + deathPlace.Id; - person.AddFact(fact); + person.SetFact(fact); - List names = new List(); + Names names = new Names(); Name name = new Name(); NameForm nameForm = new NameForm(); nameForm.SetFullText("George Washington"); @@ -147,7 +148,7 @@ private Person CreateGeorge(PlaceDescription birthPlace, PlaceDescription deathP return person; } - private Person CreateMartha(PlaceDescription birthPlace, PlaceDescription deathPlace) + private static Person CreateMartha(PlaceDescription birthPlace, PlaceDescription deathPlace) { Person person = new Person(); person.SetGender(new Gender(GenderType.Male)); @@ -164,7 +165,7 @@ private Person CreateMartha(PlaceDescription birthPlace, PlaceDescription deathP fact.Place.SetOriginal(birthPlace.Names[0].Value.ToLower()); fact.Place.DescriptionRef = "#" + birthPlace.Id; - person.AddFact(fact); + person.SetFact(fact); fact = new Fact(); fact.SetId("654"); @@ -178,9 +179,9 @@ private Person CreateMartha(PlaceDescription birthPlace, PlaceDescription deathP fact.Place.SetOriginal(deathPlace.Names[0].Value.ToLower()); fact.Place.DescriptionRef = "#" + deathPlace.Id; - person.AddFact(fact); + person.SetFact(fact); - List names = new List(); + Names names = new Names(); Name name = new Name(); NameForm nameForm = new NameForm(); nameForm.SetFullText("Martha Dandridge Custis"); @@ -204,7 +205,7 @@ private Person CreateMartha(PlaceDescription birthPlace, PlaceDescription deathP return person; } - private Relationship CreateMarriage(Person george, Person martha) + private static Relationship CreateMarriage(Person george, Person martha) { Relationship relationship = new Relationship(); relationship.SetId("DDD-DDDD"); @@ -220,7 +221,7 @@ private Relationship CreateMarriage(Person george, Person martha) return relationship; } - private List CiteGeorgeMarthaAndMarriage(Person george, Person martha, Relationship relationship) + private static List CiteGeorgeMarthaAndMarriage(Person george, Person martha, Relationship relationship) { SourceDescription georgeSource = new SourceDescription(); georgeSource.SetId("EEE-EEEE"); diff --git a/Gedcomx.Rs.Api.Test/MemoriesTests.cs b/Gedcomx.Rs.Api.Test/MemoriesTests.cs index 17feecf..32dbcd9 100644 --- a/Gedcomx.Rs.Api.Test/MemoriesTests.cs +++ b/Gedcomx.Rs.Api.Test/MemoriesTests.cs @@ -267,7 +267,7 @@ public void TestDeletePersonMemoryReference() // Confirm it is there. var state2 = tree.ReadPerson(new Uri(person.GetSelfUri())); - Assert.That(state2.Person.Evidence, Is.Not.Empty); + Assert.That(state2.Person.AnyEvidence(), Is.True); // Now delete it var state = state2.DeletePersonaReference(state2.Person.Evidence.Single()); @@ -313,7 +313,7 @@ public void TestDeleteMemoryPersona() // Confirm it is there. var personas = tree.ReadPerson(new Uri(person.GetSelfUri())); - Assert.That(personas.Person.Evidence, Is.Not.Empty); + Assert.That(personas.Person.AnyEvidence(), Is.True); var state = personas.DeletePersonaReference(personas.GetPersonaReference()); diff --git a/Gedcomx.Rs.Api.Test/PedigreeTests.cs b/Gedcomx.Rs.Api.Test/PedigreeTests.cs index 2f75ca8..07a1737 100644 --- a/Gedcomx.Rs.Api.Test/PedigreeTests.cs +++ b/Gedcomx.Rs.Api.Test/PedigreeTests.cs @@ -93,9 +93,9 @@ public void TestReadPersonAncestryAndAdditionalPersonDetails() Assert.That(state.Tree.Root.Father.Person, Is.Not.Null); Assert.That(state.Tree.Root.Father.Father, Is.Not.Null); Assert.That(state.Tree.Root.Father.Father.Person, Is.Not.Null); - Assert.That(state.Tree.Root.Person.Facts, Is.Not.Null); - Assert.That(state.Tree.Root.Father.Person.Facts, Is.Not.Null); - Assert.That(state.Tree.Root.Father.Father.Person.Facts, Is.Not.Null); + Assert.That(state.Tree.Root.Person.AnyFacts(), Is.True); + Assert.That(state.Tree.Root.Father.Person.AnyFacts(), Is.True); + Assert.That(state.Tree.Root.Father.Father.Person.AnyFacts(), Is.True); Assert.That(state.Tree.Root.Father.Father.Person.GetLink("self").Href, Is.EqualTo(grandfather.GetSelfUri())); Assert.That(state.Tree.Root.Father.Person.GetLink("self").Href, Is.EqualTo(father.GetSelfUri())); Assert.That(state.Tree.Root.Person.GetLink("self").Href, Is.EqualTo(son.GetSelfUri())); @@ -173,8 +173,8 @@ public void TestReadPersonAncestryWithSpecifiedSpouseAndAdditionalPersonAndMarri Assert.That(state.Tree.Root.Father.Father.Person, Is.Not.Null); Assert.That(state.Tree.Root.Father.Father.Father, Is.Not.Null); Assert.That(state.Tree.Root.Father.Father.Father.Person, Is.Not.Null); - Assert.That(state.Tree.Root.Father.Person.Facts, Is.Not.Null); - Assert.That(state.Tree.Root.Mother.Person.Facts, Is.Not.Null); + Assert.That(state.Tree.Root.Father.Person.AnyFacts(), Is.True); + Assert.That(state.Tree.Root.Mother.Person.AnyFacts(), Is.True); Assert.That(state.Tree.Root.Father.Father.Father.Person.GetLink("self").Href, Is.EqualTo(grandfather.GetSelfUri())); Assert.That(state.Tree.Root.Father.Father.Person.GetLink("self").Href, Is.EqualTo(father.GetSelfUri())); Assert.That(state.Tree.Root.Father.Person.GetLink("self").Href, Is.EqualTo(husband.GetSelfUri())); @@ -228,8 +228,8 @@ public void TestReadPersonDescendancyAndAdditionalPersonAndMarriageDetails() Assert.That(state.Tree.Root.Children, Is.Not.Null); Assert.That(state.Tree.Root.Spouse.DisplayExtension, Is.Not.Null); Assert.That(state.Tree.Root.Spouse.DisplayExtension.MarriageDate, Is.Not.Null); - Assert.That(state.Tree.Root.Person.Facts, Is.Not.Null); - Assert.That(state.Tree.Root.Spouse.Facts, Is.Not.Null); + Assert.That(state.Tree.Root.Person.AnyFacts(), Is.True); + Assert.That(state.Tree.Root.Spouse.AnyFacts, Is.True); Assert.That(state.Tree.Root.Children, Has.Count.EqualTo(1)); Assert.That(state.Tree.Root.Children[0].Person, Is.Not.Null); Assert.That(state.Tree.Root.Person.Id, Is.EqualTo(father.Person.Id)); @@ -290,8 +290,8 @@ public void TestReadPersonDescendancyWithSpecifiedSpouseAndAdditionalPersonAndMa Assert.That(state.Tree.Root.Children, Is.Not.Null); Assert.That(state.Tree.Root.Spouse.DisplayExtension, Is.Not.Null); Assert.That(state.Tree.Root.Spouse.DisplayExtension.MarriageDate, Is.Not.Null); - Assert.That(state.Tree.Root.Person.Facts, Is.Not.Null); - Assert.That(state.Tree.Root.Spouse.Facts, Is.Not.Null); + Assert.That(state.Tree.Root.Person.AnyFacts(), Is.True); + Assert.That(state.Tree.Root.Spouse.AnyFacts, Is.True); Assert.That(state.Tree.Root.Children, Has.Count.EqualTo(1)); Assert.That(state.Tree.Root.Children[0].Person, Is.Not.Null); Assert.That(state.Tree.Root.Person.Id, Is.EqualTo(father.Person.Id)); diff --git a/Gedcomx.Rs.Api.Test/PersonTests.cs b/Gedcomx.Rs.Api.Test/PersonTests.cs index be55fb4..a991ad7 100644 --- a/Gedcomx.Rs.Api.Test/PersonTests.cs +++ b/Gedcomx.Rs.Api.Test/PersonTests.cs @@ -106,7 +106,7 @@ public void TestCreateDiscussionReference() Assert.DoesNotThrow(() => state.IfSuccessful()); Assert.That(state.Response.StatusCode, Is.EqualTo(HttpStatusCode.Created)); - Assert.That(state2.Person.DiscussionReferences, Is.Not.Empty); + Assert.That(state2.Person.AnyDiscussionReferences(), Is.True); } [Test] @@ -266,7 +266,7 @@ public void TestReadDiscussionReferences() Assert.DoesNotThrow(() => state.IfSuccessful()); Assert.That(state.Response.StatusCode, Is.EqualTo(HttpStatusCode.OK)); - Assert.That(state.Person.DiscussionReferences, Is.Not.Empty); + Assert.That(state.Person.AnyDiscussionReferences(), Is.True); } [Test, Category("AccountNeeded")] @@ -867,7 +867,7 @@ public void TestReadPersonMergeConstraintCanMergeOtherOrderOnly() var state = person1.ReadMergeOptions(person2); Assert.DoesNotThrow(() => state.IfSuccessful()); Assert.That(state.Response.StatusCode, Is.EqualTo(HttpStatusCode.OK)); - Assert.IsFalse(state.IsAllowed); + Assert.That(state.IsAllowed, Is.False); } [Test, Category("AccountNeeded")] diff --git a/Gedcomx.Rs.Api.Test/TestBacking.cs b/Gedcomx.Rs.Api.Test/TestBacking.cs index e7e3799..25dd679 100644 --- a/Gedcomx.Rs.Api.Test/TestBacking.cs +++ b/Gedcomx.Rs.Api.Test/TestBacking.cs @@ -7,6 +7,7 @@ using Gx.Common; using Gx.Conclusion; using Gx.Fs.Tree; +using Gx.Model.Collections; using Gx.Rs.Api; using Gx.Source; using Gx.Types; @@ -32,7 +33,7 @@ public static Person GetPersonForDeepCompare() Notes = new List(), ExtensionElementsXml = new List(), }, - Names = new List() + Names = new Names() { new Name() { @@ -229,7 +230,7 @@ public static Person GetCreateMalePerson() { return new Person() .SetLiving(false) - .SetGender(new Gender().SetType(GenderType.Male)) + .SetGender(new Gender(GenderType.Male)) .SetName(new Name() .SetType(NameType.BirthName) .SetNameForm(new NameForm() @@ -267,7 +268,7 @@ public static Person GetCreateFemalePerson() { return new Person() .SetLiving(false) - .SetGender(new Gender().SetType(GenderType.Female)) + .SetGender(new Gender(GenderType.Female)) .SetName(new Name() .SetType(NameType.BirthName) .SetNameForm(new NameForm() @@ -439,7 +440,7 @@ public static string GetFactId(Person person, string factType) { string result = null; - if (person != null && person.Facts != null) + if (person != null && person.AnyFacts()) { result = person.Facts.Where(x => x.Type == factType).Select(x => x.Id).FirstOrDefault(); } diff --git a/Gedcomx.Rs.Api/PersonState.cs b/Gedcomx.Rs.Api/PersonState.cs index f0eea06..34eb4c1 100644 --- a/Gedcomx.Rs.Api/PersonState.cs +++ b/Gedcomx.Rs.Api/PersonState.cs @@ -8,6 +8,7 @@ using Gx.Common; using Gx.Conclusion; using Gx.Links; +using Gx.Model.Collections; using Gx.Rs.Api.Util; using Gx.Source; @@ -245,7 +246,7 @@ public Gx.Conclusion.Conclusion GetConclusion() public Name GetName() { Person person = (Person)MainDataElement; - return person == null ? null : person.Names == null ? null : person.Names.FirstOrDefault(); + return person == null ? null : person.AnyNames() ? null : person.Names.FirstOrDefault(); } /// @@ -265,7 +266,7 @@ public Gender GetGender() public Fact GetFact() { Person person = (Person)MainDataElement; - return person == null ? null : person.Facts == null ? null : person.Facts.FirstOrDefault(); + return person == null ? null : person.AnyFacts() ? null : person.Facts.FirstOrDefault(); } /// @@ -275,7 +276,7 @@ public Fact GetFact() public Note GetNote() { Person person = (Person)MainDataElement; - return person == null ? null : person.Notes == null ? null : person.Notes.FirstOrDefault(); + return person == null ? null : person.AnyNotes() ? null : person.Notes.FirstOrDefault(); } /// @@ -285,7 +286,7 @@ public Note GetNote() public SourceReference GetSourceReference() { Person person = (Person)MainDataElement; - return person == null ? null : person.Sources == null ? null : person.Sources.FirstOrDefault(); + return person == null ? null : person.AnySources() ? null : person.Sources.FirstOrDefault(); } /// @@ -295,7 +296,7 @@ public SourceReference GetSourceReference() public EvidenceReference GetEvidenceReference() { Person person = (Person)MainDataElement; - return person == null ? null : person.Evidence == null ? null : person.Evidence.FirstOrDefault(); + return person == null ? null : person.AnyEvidence() ? null : person.Evidence.FirstOrDefault(); } /// @@ -314,7 +315,7 @@ public EvidenceReference GetPersonaReference() public SourceReference GetMediaReference() { Person person = (Person)MainDataElement; - return person == null ? null : person.Media == null ? null : person.Media.FirstOrDefault(); + return person == null ? null : person.AnyMedia() ? null : person.Media.FirstOrDefault(); } /// @@ -550,27 +551,27 @@ protected String LocalSelfId /// A instance containing the REST API response. public PersonState Update(Person person, params IStateTransitionOption[] options) { - if (this.GetLink(Rel.CONCLUSIONS) != null && (person.Names != null || person.Facts != null || person.Gender != null)) + if (this.GetLink(Rel.CONCLUSIONS) != null && (person.AnyNames() || person.AnyFacts() || person.Gender != null)) { UpdateConclusions(person); } - if (this.GetLink(Rel.EVIDENCE_REFERENCES) != null && person.Evidence != null) + if (this.GetLink(Rel.EVIDENCE_REFERENCES) != null && person.AnyEvidence()) { UpdateEvidenceReferences(person); } - if (this.GetLink(Rel.MEDIA_REFERENCES) != null && person.Media != null) + if (this.GetLink(Rel.MEDIA_REFERENCES) != null && person.AnyMedia()) { UpdateMediaReferences(person); } - if (this.GetLink(Rel.SOURCE_REFERENCES) != null && person.Sources != null) + if (this.GetLink(Rel.SOURCE_REFERENCES) != null && person.AnySources()) { UpdateSourceReferences(person); } - if (this.GetLink(Rel.NOTES) != null && person.Notes != null) + if (this.GetLink(Rel.NOTES) != null && person.AnyNotes()) { UpdateNotes(person); } @@ -606,7 +607,7 @@ public PersonState AddGender(Gender gender, params IStateTransitionOption[] opti /// public PersonState AddName(Name name, params IStateTransitionOption[] options) { - return AddNames(new Name[] { name }, options); + return AddNames(new Names { name }, options); } /// @@ -617,10 +618,10 @@ public PersonState AddName(Name name, params IStateTransitionOption[] options) /// /// A instance containing the REST API response. /// - public PersonState AddNames(Name[] names, params IStateTransitionOption[] options) + public PersonState AddNames(Names names, params IStateTransitionOption[] options) { Person person = CreateEmptySelf(); - person.Names = names.ToList(); + person.Names = names; return UpdateConclusions(person, options); } @@ -677,7 +678,7 @@ public PersonState UpdateGender(Gender gender, params IStateTransitionOption[] o /// public PersonState UpdateName(Name name, params IStateTransitionOption[] options) { - return UpdateNames(new Name[] { name }, options); + return UpdateNames(new Names { name }, options); } /// @@ -688,10 +689,10 @@ public PersonState UpdateName(Name name, params IStateTransitionOption[] options /// /// A instance containing the REST API response. /// - public PersonState UpdateNames(Name[] names, params IStateTransitionOption[] options) + public PersonState UpdateNames(Names names, params IStateTransitionOption[] options) { Person person = CreateEmptySelf(); - person.Names = names.ToList(); + person.Names = names; return UpdateConclusions(person); } diff --git a/Gedcomx.Rs.Api/RelationshipState.cs b/Gedcomx.Rs.Api/RelationshipState.cs index f59b74a..22f8ddd 100644 --- a/Gedcomx.Rs.Api/RelationshipState.cs +++ b/Gedcomx.Rs.Api/RelationshipState.cs @@ -1,14 +1,16 @@ -using RestSharp; -using System; +using System; using System.Collections.Generic; using System.Linq; -using System.Text; -using Gx.Rs.Api.Util; -using Gx.Conclusion; + using Gedcomx.Model; + using Gx.Common; -using Gx.Source; +using Gx.Conclusion; using Gx.Links; +using Gx.Rs.Api.Util; +using Gx.Source; + +using RestSharp; namespace Gx.Rs.Api { @@ -154,7 +156,7 @@ public EvidenceReference EvidenceReference get { Relationship relationship = Relationship; - return relationship == null ? null : relationship.Evidence == null ? null : relationship.Evidence.FirstOrDefault(); + return relationship == null ? null : relationship.AnyEvidence() ? null : relationship.Evidence.FirstOrDefault(); } } @@ -169,7 +171,7 @@ public SourceReference MediaReference get { Relationship relationship = Relationship; - return relationship == null ? null : relationship.Media == null ? null : relationship.Media.FirstOrDefault(); + return relationship == null ? null : relationship.AnyMedia() ? null : relationship.Media.FirstOrDefault(); } } diff --git a/Gedcomx.Util/GedcomxModelVisitorBase.cs b/Gedcomx.Util/GedcomxModelVisitorBase.cs index 3f74008..caad0c2 100644 --- a/Gedcomx.Util/GedcomxModelVisitorBase.cs +++ b/Gedcomx.Util/GedcomxModelVisitorBase.cs @@ -389,7 +389,7 @@ public virtual void VisitPerson(Person person) VisitGender(person.Gender); } - if (person.Names != null) + if (person.AnyNames()) { foreach (Name name in person.Names) { @@ -397,7 +397,7 @@ public virtual void VisitPerson(Person person) } } - if (person.Facts != null) + if (person.AnyFacts()) { foreach (Fact fact in person.Facts) { @@ -405,7 +405,7 @@ public virtual void VisitPerson(Person person) } } - if (person.Fields != null) + if (person.AnyFields()) { foreach (Field field in person.Fields) { @@ -433,7 +433,7 @@ public virtual void VisitFact(Fact fact) VisitPlaceReference(fact.Place); } - if (fact.Fields != null) + if (fact.AnyFields()) { foreach (Field field in fact.Fields) { @@ -588,7 +588,7 @@ protected void VisitSubject(Subject subject) { VisitConclusion(subject); - if (subject.Media != null) + if (subject.AnyMedia()) { foreach (SourceReference reference in subject.Media) { @@ -603,7 +603,7 @@ protected void VisitSubject(Subject subject) /// The conclusion to visit. protected void VisitConclusion(Gx.Conclusion.Conclusion conclusion) { - if (conclusion.Sources != null) + if (conclusion.AnySources()) { foreach (SourceReference sourceReference in conclusion.Sources) { @@ -611,7 +611,7 @@ protected void VisitConclusion(Gx.Conclusion.Conclusion conclusion) } } - if (conclusion.Notes != null) + if (conclusion.AnyNotes()) { foreach (Note note in conclusion.Notes) {