internal override void parseJObject(JObject obj) { base.parseJObject(obj); JToken token = obj.GetValue("Identification", StringComparison.InvariantCultureIgnoreCase); if (token != null) { Identification = token.Value <string>(); } token = obj.GetValue("FamilyName", StringComparison.InvariantCultureIgnoreCase); if (token != null) { FamilyName = token.Value <string>(); } token = obj.GetValue("GivenName", StringComparison.InvariantCultureIgnoreCase); if (token != null) { GivenName = token.Value <string>(); } JArray array = obj.GetValue("MiddleName", StringComparison.InvariantCultureIgnoreCase) as JArray; if (array != null) { MiddleNames.AddRange(array.Values <string>()); } Roles.AddRange(mDatabase.extractJArray <IfcActorRole>(obj.GetValue("Roles", StringComparison.InvariantCultureIgnoreCase) as JArray)); Addresses.AddRange(mDatabase.extractJArray <IfcAddress>(obj.GetValue("Addresses", StringComparison.InvariantCultureIgnoreCase) as JArray)); }
protected string MiddleNamesDelimited(string delimiter, string appendIfNotEmpty) { string ret = MiddleNames == null ? "" : MiddleNames.ToString("D" + delimiter, null); //return delimited string if (!string.IsNullOrEmpty(ret)) { ret += appendIfNotEmpty; } return(ret); }
public string DisplayName(int charLimit) { string checkStringRevert = ""; //lets keep this around to have a fallback if the next gate is too large string checkString = ""; //GATE 0: we have to use this if nothing else checkString = $"{FirstName.Substring(0,1)} {LastName}"; //GATE 1: look at first and last names only and see if they hit the character limit checkStringRevert = checkString; checkString = $"{FirstName} {LastName}"; if (checkString.Length > charLimit) { //fallback to first initial last name. trim end of last name if still requred return((checkStringRevert).Substring(0, charLimit)); } //GATE 2: First + last + suffix checkStringRevert = checkString; checkString = $"{FirstName} {LastName} {Suffix}"; if (checkString.Length > charLimit) { return(checkStringRevert); } //GATE 3: Prefix + First + Last + suffix checkStringRevert = checkString; checkString = $"{Prefix} {FirstName} {LastName} {Suffix}"; if (checkString.Length > charLimit) { return(checkStringRevert); } //GATE 4: Prefix + First + Middle Initials + Last + suffix checkStringRevert = checkString; checkString = $"{Prefix} {FirstName} {MiddleNames.Select(f=>f.Substring(0,1)).Aggregate((f,g)=>f+" "+g)} {LastName} {Suffix}"; if (checkString.Length > charLimit) { return(checkStringRevert); } //GATE 5: GET ALL THE THINGS! checkStringRevert = checkString; checkString = FullName(); if (checkString.Length > charLimit) { return(checkStringRevert); } return(checkString); }
public override string GetStepParameters() { var parameters = new List <string>(); parameters.Add(Identification != null ? Identification.ToStepValue() : "$"); parameters.Add(FamilyName != null ? FamilyName.ToStepValue() : "$"); parameters.Add(GivenName != null ? GivenName.ToStepValue() : "$"); parameters.Add(MiddleNames != null ? MiddleNames.ToStepValue() : "$"); parameters.Add(PrefixTitles != null ? PrefixTitles.ToStepValue() : "$"); parameters.Add(SuffixTitles != null ? SuffixTitles.ToStepValue() : "$"); parameters.Add(Roles != null ? Roles.ToStepValue() : "$"); parameters.Add(Addresses != null ? Addresses.ToStepValue() : "$"); return(string.Join(", ", parameters.ToArray())); }
/// <summary> /// Returns true if CommonPerson instances are equal /// </summary> /// <param name="other">Instance of CommonPerson to be compared</param> /// <returns>Boolean</returns> public bool Equals(CommonPerson other) { if (ReferenceEquals(null, other)) { return(false); } if (ReferenceEquals(this, other)) { return(true); } return (( LastUpdateTime == other.LastUpdateTime || LastUpdateTime != null && LastUpdateTime.Equals(other.LastUpdateTime) ) && ( FirstName == other.FirstName || FirstName != null && FirstName.Equals(other.FirstName) ) && ( LastName == other.LastName || LastName != null && LastName.Equals(other.LastName) ) && ( MiddleNames == other.MiddleNames || MiddleNames != null && MiddleNames.SequenceEqual(other.MiddleNames) ) && ( Prefix == other.Prefix || Prefix != null && Prefix.Equals(other.Prefix) ) && ( Suffix == other.Suffix || Suffix != null && Suffix.Equals(other.Suffix) ) && ( OccupationCode == other.OccupationCode || OccupationCode != null && OccupationCode.Equals(other.OccupationCode) )); }
/// <summary> /// Gets the hash code /// </summary> /// <returns>Hash code</returns> public override int GetHashCode() { unchecked // Overflow is fine, just wrap { var hashCode = 41; // Suitable nullity checks etc, of course :) if (LastUpdateTime != null) { hashCode = hashCode * 59 + LastUpdateTime.GetHashCode(); } if (FirstName != null) { hashCode = hashCode * 59 + FirstName.GetHashCode(); } if (LastName != null) { hashCode = hashCode * 59 + LastName.GetHashCode(); } if (MiddleNames != null) { hashCode = hashCode * 59 + MiddleNames.GetHashCode(); } if (Prefix != null) { hashCode = hashCode * 59 + Prefix.GetHashCode(); } if (Suffix != null) { hashCode = hashCode * 59 + Suffix.GetHashCode(); } if (OccupationCode != null) { hashCode = hashCode * 59 + OccupationCode.GetHashCode(); } return(hashCode); } }
//public string ToString(string format) //{ // Dictionary<string, string> replacements = new Dictionary<string, string> // { // { "Tt", Title?.CapitalizeAll() }, // { "TT", Title?.ToUpper() }, // { "tt", Title?.ToLower() }, // { "Ff", Forename?.CapitalizeAll() }, // { "FF", Forename?.ToUpper() }, // { "ff", Forename?.ToLower() }, // { "F", Forename?.FirstOrDefault().ToString().ToUpper() }, // { "f", Forename?.FirstOrDefault().ToString().ToLower() }, // { "Mm", string.Join(' ', MiddleNames.Select(m => m?.CapitalizeAll())) }, // { "MM", string.Join(' ', MiddleNames.Select(m => m?.ToUpper())) }, // { "mm", string.Join(' ', MiddleNames.Select(m => m?.ToLower())) }, // { "M.", string.Join(' ', MiddleNames.Select(m => $"{m?.FirstOrDefault().ToString().ToUpper()}.")) }, // { "m.", string.Join(' ', MiddleNames.Select(m => $"{m?.FirstOrDefault().ToString().ToLower()}.")) }, // { "M", string.Join(' ', MiddleNames.Select(m => m?.FirstOrDefault().ToString().ToUpper())) }, // { "m", string.Join(' ', MiddleNames.Select(m => m?.FirstOrDefault().ToString().ToLower())) }, // { "Ll", Surname?.CapitalizeAll() }, // { "LL", Surname?.ToUpper() }, // { "ll", Surname?.ToLower() }, // { "L", Surname?.FirstOrDefault().ToString().ToUpper() }, // { "l", Surname?.FirstOrDefault().ToString().ToLower() }, // { "Ss", (Suffix ?? "").IsRomanNumeral() ? Suffix?.ToUpper() : Suffix?.CapitalizeAll() }, // { "SS", Suffix?.ToUpper() }, // { "ss", Suffix?.ToLower() } // }; // return format.ReplaceAll(replacements); //} public string ToString(NameFormat format) { string titleFormatted = Title?.ToString(format.TitleDisplayType) ?? string.Empty; string givenNamesFormatted = $"{Forename?.ToString(format.ForenameDisplayType)} {string.Join(' ', MiddleNames.Select(n => n?.ToString(format.MiddleNameDisplayType)))}".Trim(); string surnameFormatted = Surname?.ToString(format.SurnameDisplayType) ?? string.Empty; string suffixFormatted = Suffix?.ToString(format.SuffixDisplayType) ?? string.Empty; StringBuilder fullName = new StringBuilder(titleFormatted); switch (format.NameOrder) { case NameOrder.Eastern: if (fullName.Length > 0 && !string.IsNullOrWhiteSpace(surnameFormatted)) { fullName.Append(' '); } fullName.Append(surnameFormatted); if (fullName.Length > 0 && !string.IsNullOrWhiteSpace(givenNamesFormatted)) { fullName.Append(' '); } fullName.Append(givenNamesFormatted); break; case NameOrder.WesternReversed: if (fullName.Length > 0 && !string.IsNullOrWhiteSpace(surnameFormatted)) { fullName.Append(' '); } fullName.Append(surnameFormatted); if (fullName.Length > 0 && !string.IsNullOrWhiteSpace(givenNamesFormatted)) { fullName.Append(", "); } fullName.Append(givenNamesFormatted); break; case NameOrder.Western: default: if (fullName.Length > 0 && !string.IsNullOrWhiteSpace(givenNamesFormatted)) { fullName.Append(' '); } fullName.Append(givenNamesFormatted); if (fullName.Length > 0 && !string.IsNullOrWhiteSpace(surnameFormatted)) { fullName.Append(' '); } fullName.Append(surnameFormatted); break; } if (fullName.Length > 0 && !string.IsNullOrWhiteSpace(suffixFormatted)) { fullName.Append(' '); } fullName.Append(suffixFormatted); return(fullName.ToString()); }
public string FullName() { return($"{Prefix} {FirstName} {MiddleNames.Aggregate((f,g)=>f+" "+g)} {LastName} {Suffix}"); }