public string ToFullName(PersonalNameProperties includedFields, string orgName = null, bool lastFirst = true) => ToFullName(orgName, includeMiddle: includedFields.HasFlag(PersonalNameProperties.Middle), includePrefix: includedFields.HasFlag(PersonalNameProperties.Prefix), includeSuffix: includedFields.HasFlag(PersonalNameProperties.Suffix), includeNickname: includedFields.HasFlag(PersonalNameProperties.Nickname), lastFirst );
/// <summary> /// Indexer for name properties. /// </summary> /// <param name="name">The name property to get or set.</param> /// <returns>The value of the name property.</returns> public string this[PersonalNameProperties name] { get { switch (name) { case PersonalNameProperties.First: return(First.HasValue() ? First : string.Empty); case PersonalNameProperties.Last: return(Last.HasValue() ? Last : string.Empty); case PersonalNameProperties.Middle: return(Middle.HasValue() ? Middle : string.Empty); case PersonalNameProperties.Nickname: return(Nickname.HasValue() ? Nickname : string.Empty); case PersonalNameProperties.Prefix: return(Prefix.HasValue() ? Prefix : string.Empty); case PersonalNameProperties.Suffix: return(Suffix.HasValue() ? Suffix : string.Empty); default: return(string.Empty); } } set { switch (name) { case PersonalNameProperties.First: First = value.HasValue() ? value.Trim() : string.Empty; break; case PersonalNameProperties.Last: Last = value.HasValue() ? value.Trim() : string.Empty; break; case PersonalNameProperties.Middle: Middle = value.HasValue() ? value.Trim() : string.Empty; break; case PersonalNameProperties.Nickname: Nickname = value.HasValue() ? value.Trim() : string.Empty; break; case PersonalNameProperties.Prefix: Prefix = value.HasValue() ? value.Trim() : string.Empty; break; case PersonalNameProperties.Suffix: Suffix = value.HasValue() ? value.Trim() : string.Empty; break; default: break; } } }
/// <summary> /// Get the value of the specified name property /// </summary> /// <param name="name">The name property to retrieve</param> /// <param name="maxLen">The maximum length of the value to return. If the actual value is longer, it is <see cref="TextExtensions.Truncate(string, int)"/>d to the specified length.</param> /// <returns>Either <see cref="string.Empty"/> (for null or empty values) or the value of the name property truncated to the specified maxLen (if applicable).</returns> public string GetValue(PersonalNameProperties name, int maxLen = 50) { switch (name) { case PersonalNameProperties.First: return(First.HasValue() ? First.Truncate(maxLen) : string.Empty); case PersonalNameProperties.Last: return(Last.HasValue() ? Last.Truncate(maxLen) : string.Empty); case PersonalNameProperties.Middle: return(Middle.HasValue() ? Middle.Truncate(maxLen) : string.Empty); case PersonalNameProperties.Nickname: return(Nickname.HasValue() ? Nickname.Truncate(maxLen) : string.Empty); case PersonalNameProperties.Prefix: return(Prefix.HasValue() ? Prefix.Truncate(maxLen) : string.Empty); case PersonalNameProperties.Suffix: return(Suffix.HasValue() ? Suffix.Truncate(50) : string.Empty); default: return(string.Empty); } }