private static void AddAddressPropertyIfPossible(string contactPropertyName, System.Device.Location.CivicAddress civicAddress, IDictionary <string, object> contactProps) { // Mapping is very difficult and not 1:1 // *** VCard 2.1 specs -> Windows.Phone.PersonalInformation.ContactAddress // The property value is a concatenation of the // Post Office Address (first field) = ? (Missing) // Extended Address (second field) = ? (Missing) // Street (third field) = contactAddress.StreetAddress // Locality (fourth field) = contactAddress.Locality // Region (fifth field) = contactAddress.Region // Postal Code (six field) = contactAddress.PostalCode // Country (seventh field) = contactAddress.Country // An example of this property follows: // ADR;DOM;HOME:P.O. Box 101;Suite 101;123 Main Street;Any Town;CA;91921-1234; // *** System.Device.Location.CivicAddress // * CivicAddress * * Mapping to ContactAddress* // AddressLine1: Gets or sets the first line of the address. -> Street // AddressLine2: Gets or sets the second line of the address. -> +Street (?) // Building: Gets or sets the building name or number. -> +Street (??) // City: Gets or sets the name of the city. -> Locality (?) // CountryRegion: Gets or sets the country or region of the location. -> Country // FloorLevel: Gets or sets the floor level of the location. -> +Street (??) // PostalCode: Gets or sets the postal code of the location. -> PostalCode // StateProvince: Gets or sets the state or province of the location. -> Region // IsUnknown: Gets a value that indicates whether the CivicAddress contains data. // Linefeeds seem to work fine in the mapping - understood by WP + Symbian. But trigger quoted printable encoding, increasing vCard size. var contactAddress = new Windows.Phone.PersonalInformation.ContactAddress(); contactAddress.StreetAddress = civicAddress.AddressLine1; if (!String.IsNullOrEmpty(civicAddress.AddressLine2)) { contactAddress.StreetAddress += "\n" + civicAddress.AddressLine2; } if (!String.IsNullOrEmpty(civicAddress.Building)) { contactAddress.StreetAddress += "\n" + civicAddress.Building; } if (!String.IsNullOrEmpty(civicAddress.FloorLevel)) { contactAddress.StreetAddress += "\n" + civicAddress.FloorLevel; } contactAddress.Locality = civicAddress.City; contactAddress.PostalCode = civicAddress.PostalCode; contactAddress.Region = civicAddress.StateProvince; contactAddress.Country = civicAddress.CountryRegion; // Finally, add our constructed address to the contact properties AddContactPropertyIfPossible(contactPropertyName, contactAddress, contactProps); }
public override void AsStoredContactProperties(ref IDictionary <string, object> properties) { Windows.Phone.PersonalInformation.ContactAddress address = new Windows.Phone.PersonalInformation.ContactAddress(); address.StreetAddress = Street; address.Locality = City; address.Region = Region; address.Country = Country; address.PostalCode = PostalCode; SetStoredContactProperty(GetKnownContactPropertiesKind(Kind), address, ref properties); }
private static void AddAddressPropertyIfPossible(string contactPropertyName, System.Device.Location.CivicAddress civicAddress, IDictionary<string, object> contactProps) { // Mapping is very difficult and not 1:1 // *** VCard 2.1 specs -> Windows.Phone.PersonalInformation.ContactAddress // The property value is a concatenation of the // Post Office Address (first field) = ? (Missing) // Extended Address (second field) = ? (Missing) // Street (third field) = contactAddress.StreetAddress // Locality (fourth field) = contactAddress.Locality // Region (fifth field) = contactAddress.Region // Postal Code (six field) = contactAddress.PostalCode // Country (seventh field) = contactAddress.Country // An example of this property follows: // ADR;DOM;HOME:P.O. Box 101;Suite 101;123 Main Street;Any Town;CA;91921-1234; // *** System.Device.Location.CivicAddress // * CivicAddress * * Mapping to ContactAddress* // AddressLine1: Gets or sets the first line of the address. -> Street // AddressLine2: Gets or sets the second line of the address. -> +Street (?) // Building: Gets or sets the building name or number. -> +Street (??) // City: Gets or sets the name of the city. -> Locality (?) // CountryRegion: Gets or sets the country or region of the location. -> Country // FloorLevel: Gets or sets the floor level of the location. -> +Street (??) // PostalCode: Gets or sets the postal code of the location. -> PostalCode // StateProvince: Gets or sets the state or province of the location. -> Region // IsUnknown: Gets a value that indicates whether the CivicAddress contains data. // Linefeeds seem to work fine in the mapping - understood by WP + Symbian. But trigger quoted printable encoding, increasing vCard size. var contactAddress = new Windows.Phone.PersonalInformation.ContactAddress(); contactAddress.StreetAddress = civicAddress.AddressLine1; if (!String.IsNullOrEmpty(civicAddress.AddressLine2)) { contactAddress.StreetAddress += "\n" + civicAddress.AddressLine2; } if (!String.IsNullOrEmpty(civicAddress.Building)) { contactAddress.StreetAddress += "\n" + civicAddress.Building; } if (!String.IsNullOrEmpty(civicAddress.FloorLevel)) { contactAddress.StreetAddress += "\n" + civicAddress.FloorLevel; } contactAddress.Locality = civicAddress.City; contactAddress.PostalCode = civicAddress.PostalCode; contactAddress.Region = civicAddress.StateProvince; contactAddress.Country = civicAddress.CountryRegion; // Finally, add our constructed address to the contact properties AddContactPropertyIfPossible(contactPropertyName, contactAddress, contactProps); }