protected override void Embed(ExtensibleData relationship) { ChildAndParentsRelationship value = relationship as ChildAndParentsRelationship; if (value != null) { if (value.MotherFacts != null) { this.MotherFacts = this.MotherFacts == null ? new List <Fact>() : this.MotherFacts; this.MotherFacts.AddRange(value.MotherFacts); } if (value.FatherFacts != null) { this.FatherFacts = this.FatherFacts == null ? new List <Fact>() : this.FatherFacts; this.FatherFacts.AddRange(value.FatherFacts); } } base.Embed(relationship); }
public static ChildAndParentsRelationship GetCreateChildAndParentsRelationship(PersonState father = null, PersonState mother = null, PersonState child = null) { var result = new ChildAndParentsRelationship(); if (father != null) { result.Father = new ResourceReference(father.GetSelfUri()); } if (mother != null) { result.Mother = new ResourceReference(mother.GetSelfUri()); } if (child != null) { result.Child = new ResourceReference(child.GetSelfUri()); } return result; }
/// <summary> /// Adds a child and parents relationship to the collection. /// </summary> /// <param name="chap">The child and parent relationship to add.</param> /// <param name="options">The options to apply before executing the REST API call.</param> /// <returns> /// A <see cref="ChildAndParentsRelationshipState"/> instance containing the REST API response. /// </returns> /// <exception cref="Gx.Rs.Api.GedcomxApplicationException">Thrown if a link to the required resource cannot be found.</exception> public ChildAndParentsRelationshipState AddChildAndParentsRelationship(ChildAndParentsRelationship chap, params IStateTransitionOption[] options) { Link link = GetLink(Rel.RELATIONSHIPS); if (link == null || link.Href == null) { throw new GedcomxApplicationException(String.Format("FamilySearch Family Tree at {0} didn't provide a 'relationships' link.", GetUri())); } FamilySearchPlatform entity = new FamilySearchPlatform(); entity.ChildAndParentsRelationships = new List<ChildAndParentsRelationship>() { chap }; IRestRequest request = RequestUtil.ApplyFamilySearchConneg(CreateAuthenticatedRequest()).Build(link.Href, Method.POST); request.SetEntity(entity); return ((FamilyTreeStateFactory)this.stateFactory).NewChildAndParentsRelationshipState(request, Invoke(request, options), this.Client, this.CurrentAccessToken); }
/// <summary> /// Adds a child and parents relationship to the collection. /// </summary> /// <param name="child">The child to add in the relationship.</param> /// <param name="father">The father to add in the relationship.</param> /// <param name="mother">The mother to add in the relationship.</param> /// <param name="options">The options to apply before executing the REST API call.</param> /// <returns> /// A <see cref="ChildAndParentsRelationshipState"/> instance containing the REST API response. /// </returns> public ChildAndParentsRelationshipState AddChildAndParentsRelationship(PersonState child, PersonState father, PersonState mother, params IStateTransitionOption[] options) { ChildAndParentsRelationship chap = new ChildAndParentsRelationship(); chap.Child = new ResourceReference(child.GetSelfUri()); if (father != null) { chap.Father = new ResourceReference(father.GetSelfUri()); } if (mother != null) { chap.Mother = new ResourceReference(mother.GetSelfUri()); } return AddChildAndParentsRelationship(chap, options); }
/// <summary> /// Reads the child and parents relationship of the current person. /// </summary> /// <param name="relationship">The relationship to be read.</param> /// <param name="options">The options to apply before executing the REST API call.</param> /// <returns> /// A <see cref="ChildAndParentsRelationshipState"/> instance containing the REST API response. /// </returns> public ChildAndParentsRelationshipState ReadChildAndParentsRelationship(ChildAndParentsRelationship relationship, params IStateTransitionOption[] options) { Link link = relationship.GetLink(Rel.RELATIONSHIP); link = link == null ? relationship.GetLink(Rel.SELF) : link; if (link == null || link.Href == null) { return null; } IRestRequest request = RequestUtil.ApplyFamilySearchConneg(CreateAuthenticatedRequest()).Build(link.Href, Method.GET); return ((FamilyTreeStateFactory)this.stateFactory).NewChildAndParentsRelationshipState(request, Invoke(request, options), this.Client, this.CurrentAccessToken); }
public virtual void VisitChildAndParentsRelationship(ChildAndParentsRelationship pcr) { this.contextStack.Push(pcr); VisitConclusion(pcr); List<Fact> facts; facts = pcr.FatherFacts; if (facts != null) { foreach (Fact fact in facts) { fact.Accept(this); } } facts = pcr.MotherFacts; if (facts != null) { foreach (Fact fact in facts) { fact.Accept(this); } } this.contextStack.Pop(); }
/** * Build out this document with a child-and-parents relationship. * * @param chap The child-and-parents relationship */ public FamilySearchPlatform SetChildAndParentsRelationship(ChildAndParentsRelationship chap) { AddChildAndParentsRelationship(chap); return this; }
/** * Add a childAndParentsRelationship to the data set. * * @param childAndParentsRelationship The childAndParentsRelationship to be added. */ public void AddChildAndParentsRelationship(ChildAndParentsRelationship childAndParentsRelationship) { if (childAndParentsRelationship != null) { if (_childAndParentsRelationships == null) _childAndParentsRelationships = new List<ChildAndParentsRelationship>(); _childAndParentsRelationships.Add(childAndParentsRelationship); } }
public override void VisitChildAndParentsRelationship(ChildAndParentsRelationship pcr) { BindIfNeeded(pcr); base.VisitChildAndParentsRelationship(pcr); }
/// <summary> /// Adds a child and parents relationship to the current relationships collection. /// </summary> /// <param name="chap">The relationship to add to the current relationships collection, with the father, mother, and child set as desired.</param> /// <param name="options">The options to apply before executing the REST API call.</param> /// <returns> /// A <see cref="ChildAndParentsRelationshipState"/> instance containing the REST API response. /// </returns> public ChildAndParentsRelationshipState AddChildAndParentsRelationship(ChildAndParentsRelationship chap, params IStateTransitionOption[] options) { FamilySearchPlatform entity = new FamilySearchPlatform(); entity.ChildAndParentsRelationships = new List<ChildAndParentsRelationship>() { chap }; IRestRequest request = RequestUtil.ApplyFamilySearchConneg(CreateAuthenticatedRequest()).Build(GetSelfUri(), Method.POST); return ((FamilyTreeStateFactory)this.stateFactory).NewChildAndParentsRelationshipState(request, Invoke(request, options), this.Client, this.CurrentAccessToken); }