public void AssignUuids_NullSpouses_OK( [ValueSource(typeof(RelationListeTypeTests), "FieldNames")] string relationName) { var rel = new RelationListeType(); rel.SetRelation(relationName, new IPersonRelationType[] { null }); rel.AssignUuids(CprToUuid); }
public void AssignUuids_EmptySpousePnr_Exception( [ValueSource(typeof(RelationListeTypeTests), "FieldNames")] string relationName) { var rel = new RelationListeType(); var subRel = rel.CreateRelation(relationName); rel.SetRelation(relationName, new IPersonRelationType[] { subRel }); rel.AssignUuids(CprToUuid); }
public RelationListeType ToRelationListeType(Func <string, Guid> cpr2uuidConverter, DPRDataContext dataContext) { Func <decimal, Guid> cpr2uuidFunc = (cpr) => cpr2uuidConverter(cpr.ToPnrDecimalString()); var ret = new RelationListeType(); // Now fill the relations var fatherPnr = Utilities.ToParentPnr(this.PersonTotal.FatherPersonalOrBirthdate); if (fatherPnr.HasValue) { ret.Fader = new PersonRelationType[] { PersonRelationType.Create( cpr2uuidFunc(fatherPnr.Value), null, null ) }; } var motherPnr = Utilities.ToParentPnr(this.PersonTotal.MotherPersonalOrBirthDate); if (motherPnr.HasValue) { ret.Moder = new PersonRelationType[] { PersonRelationType.Create (cpr2uuidFunc(motherPnr.Value), null, null ) }; } // Fill children (including adults) ret.Boern = Child.ToPersonFlerRelationTypeArray(Children, cpr2uuidFunc); // TODO : Fill custody children ret.Foraeldremyndighedsboern = null; // Normal spouse(s) ret.Aegtefaelle = CivilStatusWrapper.ToSpouses(null, this.CivilStatesAsInterface, cpr2uuidConverter); // Registered partner(s) ret.RegistreretPartner = CivilStatusWrapper.ToRegisteredPartners(null, this.CivilStatesAsInterface, cpr2uuidConverter); //TODO: Has legal authority on ret.RetligHandleevneVaergeForPersonen = null; //TODO: People who have legal authority on this person ret.Foraeldremyndighedsindehaver = null; return(ret); }
public void AssignUuids_ValidSpousePnr_CorrectUuid( [ValueSource(typeof(RelationListeTypeTests), "FieldNames")] string relationName) { var pnr = Utilities.RandomCprNumber(); var rel = new RelationListeType(); var subRel = rel.CreateRelation(relationName); subRel.CprNumber = pnr; rel.SetRelation(relationName, new IPersonRelationType[] { subRel }); rel.AssignUuids(CprToUuid); Assert.AreEqual(UuidMap[pnr].ToString(), rel.GetRelation(relationName)[0].ReferenceID.Item); }
internal static void SetRelation(this RelationListeType rel, string name, IPersonRelationType[] relations) { var prop = rel.GetType().GetProperty(name); if (relations != null) { var rels = Array.CreateInstance(prop.PropertyType.GetElementType(), relations.Length); for (int i = 0; i < relations.Length; i++) { rels.SetValue(relations[i], i); } prop.SetValue(rel, rels, null); } }
public RelationListeType ToRelationListeType(EnglishAS78207Response details, Func <string, Guid> cpr2uuidFunc) { var ret = new RelationListeType(); //Children if (details.ChildrenPNRs != null) { var childPnrs = (from pnr in details.ChildrenPNRs where pnr.Replace("-", "").Length > 0 select pnr.Replace("-", "")).ToArray(); var uuids = Array.ConvertAll <string, Guid>(childPnrs, (cpr) => cpr2uuidFunc(cpr)); ret.Boern = Array.ConvertAll <Guid, PersonFlerRelationType> ( uuids, (pId) => PersonFlerRelationType.Create(pId, null, null) ); } //Father if (Convert.ToDecimal(details.FatherPNR) > 0) { ret.Fader = new PersonRelationType[] { PersonRelationType.Create(cpr2uuidFunc(details.FatherPNR), null, null) }; } //Mother if (Convert.ToDecimal(details.MotherPNR) > 0) { ret.Fader = new PersonRelationType[] { PersonRelationType.Create(cpr2uuidFunc(details.MotherPNR), null, null) }; } // Spouse if (Convert.ToDecimal(details.SpousePNR) > 0) { var maritalStatus = Utilities.ToPartMaritalStatus(details.MaritallStatusCode[0]); var maritalStatusDate = Utilities.ToDateTime(details.MaritalStatusDate); bool isMarried = maritalStatus == CivilStatusKodeType.Gift || maritalStatus == CivilStatusKodeType.RegistreretPartner; var spouseUuid = cpr2uuidFunc(details.SpousePNR); ret.Aegtefaelle = new PersonRelationType[] { PersonRelationType.Create ( spouseUuid, isMarried? maritalStatusDate : null, isMarried? null : maritalStatusDate ) }; } // TODO: Fill other relationships such as custody return(ret); }
public virtual RelationListeType ToRelationListeType(Func<string, Guid> cpr2uuidFunc) { var ret = new RelationListeType() { Aegtefaelle = this.ToSpouses(cpr2uuidFunc), Boern = this.ToChildren(cpr2uuidFunc), Bopaelssamling = null, ErstatningAf = null, ErstatningFor = null, Fader = this.ToFather(cpr2uuidFunc), Foraeldremyndighedsboern = null, Foraeldremyndighedsindehaver = null, LokalUdvidelse = null, Moder = this.ToMother(cpr2uuidFunc), RegistreretPartner = this.ToRegisteredPartners(cpr2uuidFunc), RetligHandleevneVaergeForPersonen = null, RetligHandleevneVaergemaalsindehaver = null }; return ret; }
internal static IPersonRelationType[] GetRelation(this RelationListeType rel, string name) { return(rel.GetType().InvokeMember(name, System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.GetProperty | System.Reflection.BindingFlags.Instance, null, rel, null) as IPersonRelationType[]); }
internal static IPersonRelationType CreateRelation(this RelationListeType rel, string name) { var memberType = rel.GetType().GetProperty(name).PropertyType.GetElementType(); return(memberType.InvokeMember(null, System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.CreateInstance | System.Reflection.BindingFlags.Instance, null, rel, null) as IPersonRelationType); }