/// <summary> /// Builds the ORG property. /// </summary> private void BuildProperties_ORG( vCardPropertyCollection properties, vCard card) { // The ORG property specifies the name of the // person's company or organization. Example: // // ORG:FairMetric LLC if (!string.IsNullOrEmpty(card.Organization)) { vCardProperty property; // Add department also if (!string.IsNullOrEmpty(card.Department)) { vCardValueCollection values = new vCardValueCollection(';'); values.Add(card.Organization); values.Add(card.Department); property = new vCardProperty("ORG", values); } else { property = new vCardProperty("ORG", card.Organization); } properties.Add(property); } }
private void BuildProperties_N( vCardPropertyCollection properties, vCard card) { // The property has the following components: Family Name, // Given Name, Additional Names, Name Prefix, and Name // Suffix. Example: // // N:Pinch;David // N:Pinch;David;John // // The N property is required (see section 3.1.2 of RFC 2426). vCardValueCollection values = new vCardValueCollection(';'); values.Add(card.FamilyName); values.Add(card.GivenName); values.Add(card.AdditionalNames); values.Add(card.NamePrefix); values.Add(card.NameSuffix); vCardProperty property = new vCardProperty("N", values); properties.Add(property); }
/// <summary> /// Builds the NICKNAME property. /// </summary> private void BuildProperties_NICKNAME( vCardPropertyCollection properties, vCard card) { // The NICKNAME property specifies the familiar name // of the person, such as Jim. This is defined in // section 3.1.3 of RFC 2426. Multiple names can // be listed, separated by commas. if (card.Nicknames.Count > 0) { // A NICKNAME property is a comma-separated // list of values. Create a value list and // add the nicknames collection to it. vCardValueCollection values = new vCardValueCollection(','); values.Add(card.Nicknames); // Create the new properties with each name separated // by a comma. vCardProperty property = new vCardProperty("NICKNAME", values); properties.Add(property); } }
private void BuildProperties_CATEGORIES( vCardPropertyCollection properties, vCard card) { if (card.Categories.Count > 0) { vCardValueCollection values = new vCardValueCollection(','); foreach (string category in card.Categories) { if (!string.IsNullOrEmpty(category)) { values.Add(category); } } properties.Add( new vCardProperty("CATEGORIES", values)); } }
/// <summary> /// Builds ADR properties. /// </summary> private void BuildProperties_ADR( vCardPropertyCollection properties, vCard card) { foreach (vCardDeliveryAddress address in card.DeliveryAddresses) { // Do not generate a postal address (ADR) property // if the entire address is blank. if ( (!string.IsNullOrEmpty(address.City)) || (!string.IsNullOrEmpty(address.Country)) || (!string.IsNullOrEmpty(address.PostalCode)) || (!string.IsNullOrEmpty(address.Region)) || (!string.IsNullOrEmpty(address.Street))) { // The ADR property contains the following // subvalues in order. All are required: // // - Post office box // - Extended address // - Street address // - Locality (e.g. city) // - Region (e.g. province or state) // - Postal code (e.g. ZIP code) // - Country name vCardValueCollection values = new vCardValueCollection(';'); values.Add(string.Empty); values.Add(string.Empty); values.Add(address.Street); values.Add(address.City); values.Add(address.Region); values.Add(address.PostalCode); values.Add(address.Country); vCardProperty property = new vCardProperty("ADR", values); if (address.IsDomestic) { property.Subproperties.Add("TYPE", "DOM"); } if (address.IsInternational) { property.Subproperties.Add("TYPE", "INTL"); } if (address.IsParcel) { property.Subproperties.Add("TYPE", "PARCEL"); } if (address.IsPostal) { property.Subproperties.Add("TYPE", "POSTAL"); } if (address.IsHome) { property.Subproperties.Add("TYPE", "HOME"); } if (address.IsWork) { property.Subproperties.Add("TYPE", "WORK"); } properties.Add(property); } } }