public PostalAddressFormat Format(PostalAddress postalAddress) { if (_postalAddressFormatters.ContainsKey(postalAddress.AddressType.ToLowerInvariant())) { return _postalAddressFormatters[postalAddress.AddressType.ToLowerInvariant()].Format(postalAddress); } return Empty; }
private static string GetAddressLine1(PostalAddress postalAddress) { string unitType = string.IsNullOrWhiteSpace(postalAddress.UnitType) ? string.Empty : postalAddress.UnitType.ToLowerInvariant(); if (string.IsNullOrWhiteSpace(unitType)) { return string.Format("{0} {1}", postalAddress.StreetNumber, postalAddress.StreetName); } if (IsNumeric(postalAddress.StreetNumber) && IsAlphaOnly(postalAddress.UnitId)) { return string.Format("{0}{2} {1}", postalAddress.StreetNumber, postalAddress.StreetName, postalAddress.UnitId); } return string.Format("{2}/{0} {1}", postalAddress.StreetNumber, postalAddress.StreetName, postalAddress.UnitId); }
public PostalAddressFormat Format(PostalAddress postalAddress) { if (postalAddress == null) throw new ArgumentNullException("postalAddress", "postalAddress is null."); if (postalAddress.AddressType.ToLowerInvariant() != "bag") { throw new ArgumentOutOfRangeException("postalAddress", string.Format("Invalid AddressType. Expected 'bag' but was '{0}'", postalAddress.AddressType.ToLowerInvariant())); } PostalAddressFormat format = new PostalAddressFormat(); format.AddressType = postalAddress.AddressType; format.AddressLine1 = GetAddressLine1(postalAddress); format.AddressLine2 = postalAddress.BoxBagLobbyName; format.AddressLine3 = string.Empty; format.Suburb = string.Empty; format.City = postalAddress.TownCityMailTown; format.PostCode = postalAddress.PostCode; format.AddressOneLine = string.Join(", ", new string[] { format.AddressLine1, format.Suburb, format.City, format.PostCode }); return format; }
public PostalAddressFormat Format(PostalAddress postalAddress) { if (postalAddress == null) throw new ArgumentNullException("postalAddress", "postalAddress is null."); if (postalAddress.AddressType.ToLowerInvariant() != "urban") { throw new ArgumentOutOfRangeException("postalAddress", string.Format("Invalid AddressType. Expected 'urban' but was '{0}'", postalAddress.AddressType.ToLowerInvariant())); } PostalAddressFormat format = new PostalAddressFormat(); format.AddressType = postalAddress.AddressType; format.AddressLine1 = GetAddressLine1(postalAddress); format.AddressLine2 = GetAddressLine2(postalAddress); format.AddressLine3 = postalAddress.SuburbName != format.AddressLine2 ? postalAddress.SuburbName : string.Empty; format.Suburb = postalAddress.SuburbName; format.City = postalAddress.TownCityMailTown; format.PostCode = postalAddress.PostCode; format.AddressOneLine = string.Join(", ", string.Join("~", new string[] { format.AddressLine1, format.AddressLine2, format.AddressLine3, string.Format("{0} {1}", format.City, format.PostCode) }).Split("~".ToCharArray(), StringSplitOptions.RemoveEmptyEntries).ToArray()); return format; }
private static PostalAddress Convert(REDPostalAddressImport postalAddress) { var result = new PostalAddress(); result.AddressType = postalAddress.AddressType; result.BoxBagLobbyName = postalAddress.BoxBagLobbyName; result.BoxBagNumber = postalAddress.BoxBagNumber; result.BuildingName = postalAddress.BuildingName; result.DeliveryServiceType = postalAddress.DeliveryServiceType; result.Floor = GetFloor(postalAddress.Floor); result.Id = postalAddress.Id; result.PostCode = postalAddress.PostCode; result.RDNumber = postalAddress.RDNumber; result.StreetAlpha = postalAddress.StreetAlpha; result.StreetDirection = postalAddress.StreetDirection; result.StreetName = postalAddress.StreetName; result.StreetNumber = postalAddress.StreetNumber; result.StreetType = postalAddress.StreetType; result.SuburbName = postalAddress.SuburbName; result.TownCityMailTown = postalAddress.TownCityMailTown; result.UnitId = postalAddress.UnitId; result.UnitType = postalAddress.UnitType; result.AddressLine = new PostalAddressFormatter().Format(result).AddressOneLine; return result; }
private static PostalAddress Convert(PAFPostalAddressImport postalAddress) { var result = new PostalAddress(); result.AddressType = postalAddress.AddressType; result.BoxBagLobbyName = ToTitleCase(postalAddress.BoxBagLobbyName); result.BoxBagNumber = postalAddress.BoxBagNumber; result.BuildingName = ToTitleCase(postalAddress.BuildingName); result.DeliveryServiceType = postalAddress.DeliveryServiceType; result.Floor = ToTitleCase(postalAddress.Floor); result.Id = postalAddress.Id; result.PostCode = postalAddress.PostCode; result.RDNumber = postalAddress.RDNumber; result.StreetAlpha = postalAddress.StreetAlpha; result.StreetDirection = ToTitleCase(postalAddress.StreetDirection); result.StreetName = string.Join(" ", string.Join("|", new string[] { ToTitleCase(postalAddress.StreetName), ToTitleCase(postalAddress.StreetType), ToTitleCase(postalAddress.StreetDirection) }).Split("|".ToCharArray(), StringSplitOptions.RemoveEmptyEntries)); result.StreetNumber = postalAddress.StreetNumber; result.StreetType = postalAddress.StreetType; result.SuburbName = ToTitleCase(postalAddress.SuburbName); result.TownCityMailTown = ToTitleCase(postalAddress.TownCityMailTown); result.UnitId = postalAddress.UnitId; result.UnitType = postalAddress.UnitType; result.AddressLine = new PostalAddressFormatter().Format(result).AddressOneLine; return result; }
private static string GetAddressLine1(PostalAddress postalAddress) { return string.Format("{0} {1}", postalAddress.DeliveryServiceType, postalAddress.BoxBagNumber); }
private static string GetAddressLine2(PostalAddress postalAddress) { return string.Format("RD {0}", postalAddress.RDNumber); }