Ejemplo n.º 1
0
        /// <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);

            }

        }
Ejemplo n.º 2
0
        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));

            }

        }
Ejemplo n.º 3
0
        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);

        }
Ejemplo n.º 4
0
        /// <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("DOM");

                    if (address.IsInternational)
                        property.Subproperties.Add("INTL");

                    if (address.IsParcel)
                        property.Subproperties.Add("PARCEL");

                    if (address.IsPostal)
                        property.Subproperties.Add("POSTAL");

                    if (address.IsHome)
                        property.Subproperties.Add("HOME");

                    if (address.IsWork)
                        property.Subproperties.Add("WORK");

                    properties.Add(property);

                }

            }

        }