private void ReadInto_XSocialProfile(vCard card, vCardProperty property)
        {

            vCardSocialProfile sp = new vCardSocialProfile();
 

            sp.ProfileUrl = property.ToString();
            if (string.IsNullOrEmpty(sp.ProfileUrl))
                return;

            foreach (vCardSubproperty subproperty in property.Subproperties)
            {

                switch (subproperty.Name.ToUpperInvariant())
                {

                    case "X-USER":

                        sp.Username = subproperty.Value;

                        break;

                    case "TYPE":
              

                        string[] typeValues =
                            subproperty.Value.Split(new char[] { ',' });

                        foreach (string typeValue in typeValues)
                        {

                            SocialProfileServiceType? profileType = SocialProfileTypeUtils.GetSocialProfileServiceType(typeValue);


                                if (profileType.HasValue)
                                {
                                    sp.ServiceType = profileType.Value;


                                }
 

                 

                        }
                        break;

                }

            }

            card.SocialProfiles.Add(sp);

        }
Exemplo n.º 2
0
        /// <summary>
        ///     Reads a SOCIALPROFILE property.
        /// </summary>
        private void ReadInto_X_SOCIALPROFILE(vCard card, vCardProperty property)
        {

            var profile = new vCardSocialProfile();

            // The social address is stored as the value of the property.
            // The format of the address depends on the type of social
            // address.  The current version of the library does not
            // perform any validation.

            profile.Address = property.Value.ToString();

            // Loop through each subproperty and look for flags
            // that indicate the type of social address.

            foreach (vCardSubproperty subproperty in property.Subproperties)
            {
                vCardSocialProfileType? profileType = vCardSocialProfileType.Other;
                switch (subproperty.Name.ToUpperInvariant())
                {

                    case "PREF":

                        // The PREF subproperty indicates the social
                        // address is the preferred social address to
                        // use when contacting the person.

                        profile.IsPreferred = true;
                        break;

                    default:

                        if (subproperty.Name.StartsWith("X-", StringComparison.OrdinalIgnoreCase))
                        {
                            if (profile.Attributes==null)profile.Attributes = new Dictionary<string, string>();
                            profile.Attributes.Add(subproperty.Name.ToUpperInvariant(), subproperty.Value);
                        }
                        else
                        {


                            // All other subproperties are probably vCard 2.1
                            // subproperties.  This was before the social type
                            // was supposed to be specified with TYPE=VALUE.
                            try
                            {
                                profileType = (vCardSocialProfileType?) Enum.Parse(typeof (vCardSocialProfileType), subproperty.Name, true);
                            }
                            catch (ArgumentException)
                            {
                            }
                            profile.ProfileType = profileType.Value;
                        }
                        break;

                }
            }

            card.SocialProfiles.Add(profile);

        }