public static IDictionary <AddressFormatTable.AddressPart, AddressComponent> GetAddressInfo(Item item, PhysicalAddressType type) { if (item == null) { throw new ArgumentNullException("item"); } if (type != PhysicalAddressType.Business && type != PhysicalAddressType.Home && type != PhysicalAddressType.Other) { throw new ArgumentOutOfRangeException("type", "type must be Business, Home or Other"); } IDictionary <AddressFormatTable.AddressPart, AddressComponent> dictionary = new Dictionary <AddressFormatTable.AddressPart, AddressComponent>(); AddressFormatTable.AddressPart[] cultureAddressMap = AddressFormatTable.GetCultureAddressMap(Culture.GetUserCulture().LCID); foreach (AddressFormatTable.AddressPart addressPart in cultureAddressMap) { PropertyDefinition propertyDefinition = AddressFormatTable.LookupAddressProperty(addressPart, type); string property = ItemUtility.GetProperty <string>(item, propertyDefinition, string.Empty); if (property.Length > 0) { AddressComponent value = ContactUtilities.ProcessAddressPartInternal(property, addressPart); dictionary[addressPart] = value; } } return(dictionary); }
private static AddressComponent ProcessAddressPartInternal(string addressPartValue, AddressFormatTable.AddressPart addressPart) { AddressComponent addressComponent = new AddressComponent(); addressComponent.Value = addressPartValue; string label = string.Empty; switch (addressPart) { case AddressFormatTable.AddressPart.Street: label = LocalizedStrings.GetHtmlEncoded(-883163903); break; case AddressFormatTable.AddressPart.City: label = LocalizedStrings.GetHtmlEncoded(775690683); break; case AddressFormatTable.AddressPart.State: label = LocalizedStrings.GetHtmlEncoded(2035807370); break; case AddressFormatTable.AddressPart.PostalCode: label = LocalizedStrings.GetHtmlEncoded(-1694515752); break; case AddressFormatTable.AddressPart.Country: label = LocalizedStrings.GetHtmlEncoded(-383027171); break; } addressComponent.Label = label; return(addressComponent); }
public static IDictionary <AddressFormatTable.AddressPart, AddressComponent> GetAddressInfo(IADOrgPerson orgPerson) { if (orgPerson == null) { throw new ArgumentNullException("orgPerson"); } IDictionary <AddressFormatTable.AddressPart, AddressComponent> dictionary = new Dictionary <AddressFormatTable.AddressPart, AddressComponent>(); AddressFormatTable.AddressPart[] cultureAddressMap = AddressFormatTable.GetCultureAddressMap(Culture.GetUserCulture().LCID); foreach (AddressFormatTable.AddressPart addressPart in cultureAddressMap) { PropertyDefinition property = AddressFormatTable.LookupAddressPropertyAd(addressPart); string adorgPersonStringPropertyValue = ContactUtilities.GetADOrgPersonStringPropertyValue(orgPerson, property); if (!string.IsNullOrEmpty(adorgPersonStringPropertyValue)) { AddressComponent value = ContactUtilities.ProcessAddressPartInternal(adorgPersonStringPropertyValue, addressPart); dictionary[addressPart] = value; } } return(dictionary); }