/// <summary>
 /// A simple factory method to translate from a SmartyStreetsAddress
 /// to a common Address object.
 /// </summary>
 /// <param name="add">The SmartyStreetsAddress object from which to translate.</param>
 /// <returns>A common Address object.</returns>
 public static Address FromSmartyStreetsAddress(SmartyStreetsAddress add)
 {
     return(new Address
     {
         Address1 = string.Format("{0} {1} {2} {3} {4}",
                                  add.components.primary_number,
                                  add.components.street_predirection,
                                  add.components.street_name,
                                  add.components.street_suffix,
                                  add.components.street_postdirection).Replace("  ", " ").Trim(),
         Address2 = string.Format("{0} {1}",
                                  add.components.secondary_designator,
                                  add.components.secondary_number).Replace("  ", " ").Trim(),
         City = add.components.default_city_name ?? add.components.city_name,
         State = add.components.state_abbreviation,
         Zip = add.components.zipcode
     });
 }
Example #2
0
 /// <summary>
 /// A simple factory method to translate from a SmartyStreetsAddress 
 /// to a common Address object.
 /// </summary>
 /// <param name="add">The SmartyStreetsAddress object from which to translate.</param>
 /// <returns>A common Address object.</returns>
 public static Address FromSmartyStreetsAddress(SmartyStreetsAddress add)
 {
     return new Address
     {
         Address1 = string.Format("{0} {1} {2} {3} {4}",
            add.components.primary_number,
            add.components.street_predirection,
            add.components.street_name,
            add.components.street_suffix,
            add.components.street_postdirection).Replace("  ", " ").Trim(),
         Address2 = string.Format("{0} {1}",
             add.components.secondary_designator,
             add.components.secondary_number).Replace("  ", " ").Trim(),
         City = add.components.default_city_name ?? add.components.city_name,
         State = add.components.state_abbreviation,
         Zip = add.components.zipcode
     };
 }