public static string ToLocalizedString( this IPersonName personName, PersonNameFormatterStyle style = PersonNameFormatterStyle.Default, bool usePhoneticRepresentation = false) { #if NATIVE_PERSON_NAME_COMPONENTS_AVAILABLE var jsonString = JsonStringForPersonName(personName); var localizedString = PInvoke.AppleAuth_GetPersonNameUsingFormatter(jsonString, (int)style, usePhoneticRepresentation); if (localizedString != null) { return(localizedString); } #endif var orderedParts = new System.Collections.Generic.List <string>(); if (string.IsNullOrEmpty(personName.NamePrefix)) { orderedParts.Add(personName.NamePrefix); } if (string.IsNullOrEmpty(personName.GivenName)) { orderedParts.Add(personName.GivenName); } if (string.IsNullOrEmpty(personName.MiddleName)) { orderedParts.Add(personName.MiddleName); } if (string.IsNullOrEmpty(personName.FamilyName)) { orderedParts.Add(personName.FamilyName); } if (string.IsNullOrEmpty(personName.NameSuffix)) { orderedParts.Add(personName.NameSuffix); } return(string.Join(" ", orderedParts.ToArray())); }