Ejemplo n.º 1
0
        /// <summary>
        ///     Writes a card, then reads it back and compares fields.
        /// </summary>
        public static void CycleStandard21(vCard card)
        {

            if (card == null)
                throw new ArgumentNullException("cycle");

            // Create a memory stream to hold the contents of the card.

            MemoryStream stream = new MemoryStream();

            StreamWriter textWriter = new StreamWriter(stream);

            // Create a standard vCard writer and export the
            // card data to the stream.

            vCardStandardWriter writer = new vCardStandardWriter();
            writer.Write(card, textWriter);
            textWriter.Flush();

            // Reset the stream (back to its beginning), then
            // create a stream reader capable of reading text
            // lines from the stream.

            stream.Seek(0, SeekOrigin.Begin);
            StreamReader streamReader = new StreamReader(stream);

            vCardStandardReader standardReader = new vCardStandardReader();
            vCard reloaded = standardReader.Read(streamReader);

            Equals(card, reloaded);

        }
Ejemplo n.º 2
0
        public ToxyBusinessCards Parse()
        {
            string path = Context.Path;
            ToxyBusinessCards tbcs = new ToxyBusinessCards();
            using (StreamReader sr = new StreamReader(path))
            {
                while (!sr.EndOfStream)
                {
                    var card = new vCard(sr);
                    ToxyBusinessCard tbc = new ToxyBusinessCard();
                    tbc.Name = new ToxyName();
                    if (!string.IsNullOrEmpty(card.FormattedName))
                        tbc.Name.FullName = card.FormattedName;

                    tbc.Name.FirstName = card.GivenName;
                    tbc.Name.MiddleName = card.AdditionalNames;
                    tbc.Name.LastName = card.FamilyName;
                    tbc.ProductID = card.ProductId;
                    foreach(var vSource in card.Sources)
                    {
                        tbc.Sources.Add(vSource.Uri.OriginalString);
                    }
                    tbc.Orgnization = card.Organization;
                    tbc.Title = card.Title;
                    tbc.Gender = card.Gender == vCardGender.Male ? GenderType.Male : GenderType.Female;
                    if (card.Nicknames.Count > 0)
                    {
                        tbc.NickName = new ToxyName();
                        tbc.NickName.FullName = card.Nicknames[0];
                    }
                    foreach (var dAddr in card.DeliveryAddresses)
                    {
                        var tAddr= new ToxyAddress();
                        tAddr.City = dAddr.City;
                        tAddr.Street = dAddr.Street;
                        tAddr.Country = dAddr.Country;
                        tAddr.Region = dAddr.Region;
                        tAddr.PostalCode = dAddr.PostalCode;
                        tbc.Addresses.Add(tAddr);
                    }

                    foreach (var vphone in card.Phones)
                    {
                        tbc.Contacts.Add(new ToxyContact(vphone.PhoneType.ToString(), vphone.FullNumber)); 
                    }
                    foreach (var vEmail in card.EmailAddresses)
                    {
                        tbc.Contacts.Add(new ToxyContact(vEmail.EmailType.ToString(), vEmail.Address)); 
                    }
                    foreach (var vWebsite in card.Websites)
                    {
                        tbc.Contacts.Add(new ToxyContact("Url-"+ vWebsite.WebsiteType.ToString(), vWebsite.Url));
                    }

                    tbcs.Cards.Add(tbc);
                }
            }
            return tbcs;
        }
Ejemplo n.º 3
0
        public void CycleOutlookSimple()
        {

            vCard card = new vCard(
                new StreamReader(new MemoryStream(SampleCards.OutlookSimple)));

            Helper.CycleStandard(card);

        }
Ejemplo n.º 4
0
        public void CycleXPlanWithPhoto()
        {

            vCard card = new vCard(
                new StreamReader(new MemoryStream(SampleCards.XPalmWithPhoto)));

            Helper.CycleStandard(card);

        }
Ejemplo n.º 5
0
        /// <summary>
        ///     Writes the vCard to the specified filename.
        /// </summary>
        public virtual void Write(vCard card, string filename)
        {
            if (card == null)
                throw new ArgumentNullException("card");

            using (StreamWriter output = new StreamWriter(filename))
            {
                Write(card, output);
            }
        }
Ejemplo n.º 6
0
        public void CycleOutlookCertificate()
        {

            // Load the vCard with the test certificate.

            vCard card = new vCard(
                new StreamReader(new MemoryStream(SampleCards.OutlookCertificate)));

            Helper.CycleStandard(card);

        }
		private vCard requestVCard(SID sid) {
			ensureLoggedIn();

			var getResponse = WebSession.Get(string.Format("https://intranet.avegagroup.se/templates/vcard.aspx?SID={0}&ext=.vcf", sid.Value));

			using (var stream = new StringReader(getResponse.TextContent)) {
				vCard card = new vCard(stream);
				return card;
			}

		}
Ejemplo n.º 8
0
        public void ReadWriteProperty_Department()
        {

            vCard card = new vCard();
            card.Department = "DOD";

            Assert.AreEqual(
                "DOD",
                card.Department,
                "The Department property is not working.");

        }
Ejemplo n.º 9
0
        public void ReadWriteProperty_AdditionalNames()
        {

            // Make sure .AdditionalNames reads/writes

            vCard card = new vCard();
            card.AdditionalNames = "John";

            Assert.AreEqual(
                "John",
                card.AdditionalNames,
                "The AdditionalNames property is not working.");

        }
Ejemplo n.º 10
0
        public void CycleRfcAuthors()
        {

            using (StreamReader reader = new StreamReader(
                new MemoryStream(SampleCards.RfcAuthors)))
            {

                vCard card1 = new vCard(reader);
                vCard card2 = new vCard(reader);

                Helper.CycleStandard(card1);
                Helper.CycleStandard(card2);

            }

        }
Ejemplo n.º 11
0
        public void ParseRfcAuthors()
        {

            using (StreamReader reader = new StreamReader(
                new MemoryStream(SampleCards.RfcAuthors)))
            {

                vCard card1 = new vCard(reader);
                vCard card2 = new vCard(reader);

                _parseCard1(card1);
                _parseCard2(card2);

            }


        }
Ejemplo n.º 12
0
        public void SamplevCardReadAndWriteTestWithEmailTypeFormat()
        {

            vCard card = new vCard();

            card.EmailAddresses.Add(new vCardEmailAddress() { Address = "*****@*****.**", EmailType = vCardEmailAddressType.Internet, IsPreferred = true, ItemType = ItemType.WORK });


            card.UniqueId = Guid.NewGuid().ToString("N");

            string text = card.ToString();

            vCardStandardWriter writer = new vCardStandardWriter();

            using (StringWriter sw = new StringWriter())
            {

                writer.Write(card, sw);

                sw.Flush();
                text = sw.ToString();
                sw.Close();
            }


            Assert.IsNotNull(text);


            vCardStandardReader reader = new vCardStandardReader();

            using (StringReader sr = new StringReader(text))
            {

                vCard cardFromReader = reader.Read(sr);

                Assert.AreEqual(1, cardFromReader.EmailAddresses.Count);

                var email = cardFromReader.EmailAddresses.First();
                Assert.AreEqual(true, email.IsPreferred);
                Assert.AreEqual(ItemType.WORK, email.ItemType);
                Assert.AreEqual(vCardEmailAddressType.Internet, email.EmailType);
                Assert.AreEqual("*****@*****.**", email.Address);
            }

        }
Ejemplo n.º 13
0
        public void ReadWriteProperty_BirthDate()
        {

            vCard card = new vCard();
            card.BirthDate = DateTime.Parse("04/04/04");

            Assert.AreEqual(
                DateTime.Parse("04/04/04"),
                card.BirthDate.Value,
                "The BirthDate property was not set.");

            card.BirthDate = null;

            Assert.IsNull(
                card.BirthDate,
                "The BirthDate property was not set to null.");

        }
Ejemplo n.º 14
0
        public vCard ToVCard()
        {
            vCard card = new vCard();
            if(this.Name!=null)
            {
            card.DisplayName = this.Name.FullName;
            card.FamilyName = this.Name.LastName;
            card.GivenName = this.Name.FirstName;
            }
            card.Gender = this.Gender== GenderType.Male?vCardGender.Male:vCardGender.Female;
            if (this.NickName != null)
                card.Nicknames.Add(this.NickName.FullName);

            card.Organization = this.Orgnization;
            if (this.Contacts != null)
            {
                foreach (var contact in this.Contacts)
                {
                    card.Phones.Add(new vCardPhone(contact.Name, vCardPhoneTypes.Cellular));
                }
            }
            return card;
        }
Ejemplo n.º 15
0
        public override int Run(string[] remainingArguments)
        {
            using (var stream = new StreamReader(new FileStream(Filepath, FileMode.Open)))
            {
                while (!stream.EndOfStream)
                {
                    var card = new vCard(stream);
                    var select = new
                    {
                        name = card.FormattedName,
                        phones = string.Join(",", card.Phones.Select(p => p.FullNumber)),
                        email = card.EmailAddresses
                    };

                    if (string.IsNullOrEmpty(select.phones) || string.IsNullOrEmpty(select.name))
                        continue; ;

                    Console.WriteLine(Newtonsoft.Json.JsonConvert.SerializeObject(select));
                }
            }

            return 0;
        }
Ejemplo n.º 16
0
        public void StringEmpty_Mailer()
        {

            vCard card = new vCard();

            Assert.IsEmpty(
                card.Mailer,
                "Mailer is not string.Empty.");

            card.Mailer = null;

            Assert.IsEmpty(
                card.Mailer,
                "Mailer is not string.Empty after being assigned null.");

        }
Ejemplo n.º 17
0
        private void _parseCard2(vCard card)
        {

            // 13 BEGIN:vCard
            // 14 VERSION:3.0
            // 15 FN:Tim Howes
            // 16 ORG:Netscape Communications Corp.
            // 17 ADR;TYPE=WORK:;;501 E. Middlefield Rd.;Mountain View;
            // 18  CA; 94043;U.S.A.
            // 19 TEL;TYPE=VOICE,MSG,WORK:+1-415-937-3419
            // 20 TEL;TYPE=FAX,WORK:+1-415-528-4164
            // 21 EMAIL;TYPE=INTERNET:[email protected]
            // 22 END:vCard

            Assert.AreEqual(
                "Tim Howes",
                card.FormattedName,
                "FN at line 15 is different.");

            Assert.AreEqual(
                "Netscape Communications Corp.",
                card.Organization,
                "ORG at line 16 is different.");

            // 17 ADR;TYPE=WORK:;;501 E. Middlefield Rd.;Mountain View;
            // 18  CA; 94043;U.S.A.

            Assert.AreEqual(
                1,
                card.DeliveryAddresses.Count,
                "One ADR located at lines 17-18.");

            Assert.IsTrue(
                card.DeliveryAddresses[0].IsWork,
                "ADR on lines 17-18 is a work address.");

            Assert.AreEqual(
                "501 E. Middlefield Rd.",
                card.DeliveryAddresses[0].Street,
                "ADR on lines 17-18 has a different street.");

            Assert.AreEqual(
                "Mountain View",
                card.DeliveryAddresses[0].City,
                "ADR on lines 17-18 has a different city.");

            Assert.AreEqual(
                "CA",
                card.DeliveryAddresses[0].Region,
                "ADR on lines 17-18 has a different region/state.");

            Assert.AreEqual(
                "94043",
                card.DeliveryAddresses[0].PostalCode,
                "ADR on lines 17-18 has a different postal code.");

            Assert.AreEqual(
                "U.S.A.",
                card.DeliveryAddresses[0].Country,
                "ADR on lines 17-18 has a different country.");

            // 19 TEL;TYPE=VOICE,MSG,WORK:+1-415-937-3419
            // 20 TEL;TYPE=FAX,WORK:+1-415-528-4164

            Assert.AreEqual(
                2,
                card.Phones.Count,
                "Two phones are defined on lines 19 and 20.");

            Assert.IsTrue(
                card.Phones[0].IsVoice,
                "TEL on line 19 is a voice number.");

            Assert.IsTrue(
                card.Phones[0].IsMessagingService,
                "TEL on line 19 is a messaging service number.");

            Assert.IsTrue(
                card.Phones[0].IsWork,
                "TEL on line 19 is a work number.");

            Assert.AreEqual(
                "+1-415-937-3419",
                card.Phones[0].FullNumber,
                "TEL on line 19 has a different value.");

            // 20 TEL;TYPE=FAX,WORK:+1-415-528-4164

            Assert.IsTrue(
                card.Phones[1].IsFax,
                "TEL on line 20 is a fax number.");

            Assert.IsTrue(
                card.Phones[1].IsWork,
                "TEL on line 20 is a fax number.");

            Assert.AreEqual(
                "+1-415-528-4164",
                card.Phones[1].FullNumber,
                "TEL on line 20 has a different value.");

            // 21 EMAIL;TYPE=INTERNET:[email protected]

            Assert.AreEqual(
                1,
                card.EmailAddresses.Count,
                "One email address on line 21.");

            Assert.AreEqual(
                vCardEmailAddressType.Internet,
                card.EmailAddresses[0].EmailType,
                "EMAIL on line 21 is INTERNET.");

            Assert.AreEqual(
                "*****@*****.**",
                card.EmailAddresses[0].Address,
                "EMAIL on line 21 has a different value.");

        }
Ejemplo n.º 18
0
        // The following functions compare two vCard-related objects.
        
        #region [ Equals(vCard) ]

        public static void Equals(vCard c1, vCard c2)
        {

            // Start by comparing the base fields.

            Assert.AreEqual(
                c1.AdditionalNames,
                c2.AdditionalNames,
                "AdditionalNames does not match.");

            Assert.AreEqual(
                c1.BirthDate,
                c2.BirthDate,
                "BirthDate does not match.");

            Assert.AreEqual(
                c1.DisplayName,
                c2.DisplayName,
                "DisplayName does not match.");

            Assert.AreEqual(
                c1.FamilyName,
                c2.FamilyName,
                "FamilyName does not match.");

            Assert.AreEqual(
                c1.FormattedName,
                c2.FormattedName,
                "FormattedName does not match.");

            Assert.AreEqual(
                c1.Gender,
                c2.Gender,
                "Gender does not match.");

            Assert.AreEqual(
                c1.GivenName,
                c2.GivenName,
                "GivenName does not match.");

            Assert.AreEqual(
                c1.Mailer,
                c2.Mailer,
                "Mailer does not match.");

            Assert.AreEqual(
                c1.NamePrefix,
                c2.NamePrefix,
                "NamePrefix does not match.");

            Assert.AreEqual(
                c1.NameSuffix,
                c2.NameSuffix,
                "NameSuffix does not match.");

            Assert.AreEqual(
                c1.Organization,
                c2.Organization,
                "Organization does not match.");

            Assert.AreEqual(
                c1.ProductId,
                c2.ProductId,
                "ProductId does not match.");

            Assert.AreEqual(
                c1.RevisionDate,
                c2.RevisionDate,
                "RevisionDate does not match.");

            Assert.AreEqual(
                c1.Role,
                c2.Role,
                "Role does not match.");

            Assert.AreEqual(
                c1.TimeZone,
                c2.TimeZone,
                "TimeZone does not match.");

            Assert.AreEqual(
                c1.Title,
                c2.Title,
                "Title does not match.");

            Assert.AreEqual(
                c1.ToString(),
                c2.ToString(),
                "ToString() does not match.");

            Assert.AreEqual(
                c1.UniqueId,
                c2.UniqueId,
                "UniqueId does not match.");

            // Compare collections

            Equals(
                c1.Categories,
                c2.Categories);

            Equals(
                c1.DeliveryAddresses,
                c2.DeliveryAddresses);

            Equals(
                c1.DeliveryLabels,
                c2.DeliveryLabels);

            Equals(
                c1.EmailAddresses,
                c2.EmailAddresses);

            Equals(
                c1.Nicknames,
                c2.Nicknames);

            Equals(
                c1.Notes,
                c2.Notes);

            Equals(
                c1.Phones,
                c2.Phones);

            Equals(
                c1.Photos,
                c2.Photos);

            Equals(
                c1.Sources,
                c2.Sources);

            Equals(
                c1.Websites,
                c2.Websites);

        }
Ejemplo n.º 19
0
        // The next set of functions generate raw vCard properties
        // from an object in the vCard object model.  Every method
        // has a collection (into which new properties should be
        // placed) and a vCard object (from which the properties
        // should be generated).

        #region [ BuildProperties ]

        /// <summary>
        ///     Builds a collection of standard properties based on
        ///     the specified vCard.
        /// </summary>
        /// <returns>
        ///     A <see cref="vCardPropertyCollection"/> that contains all
        ///     properties for the current vCard, including the header
        ///     and footer properties.
        /// </returns>
        /// <seealso cref="vCard"/>
        /// <seealso cref="vCardProperty"/>
        private vCardPropertyCollection BuildProperties(
            vCard card)
        {
            vCardPropertyCollection properties =
                new vCardPropertyCollection();

            // The BEGIN:VCARD line marks the beginning of
            // the vCard contents.  Later it will end with END:VCARD.
            // See section 2.1.1 of RFC 2426.

            properties.Add(new vCardProperty("BEGIN", "VCARD"));

            BuildProperties_NAME(
                properties,
                card);

            BuildProperties_SOURCE(
                properties,
                card);

            BuildProperties_N(
                properties,
                card);

            BuildProperties_FN(
                properties,
                card);

            BuildProperties_ADR(
                properties,
                card);

            BuildProperties_BDAY(
                properties,
                card);

            BuildProperties_CATEGORIES(
                properties,
                card);

            BuildProperties_CLASS(
                properties,
                card);

            BuildProperties_EMAIL(
                properties,
                card);

            BuildProperties_GEO(
                properties,
                card);

            BuildProperties_KEY(
                properties,
                card);

            BuildProperties_LABEL(
                properties,
                card);

            BuildProperties_MAILER(
                properties,
                card);

            BuildProperties_NICKNAME(
                properties,
                card);

            BuildProperties_NOTE(
                properties,
                card);

            BuildProperties_ORG(
                properties,
                card);

            BuildProperties_PHOTO(
                properties,
                card);

            BuildProperties_PRODID(
                properties,
                card);

            BuildProperties_REV(
                properties,
                card);

            BuildProperties_ROLE(
                properties,
                card);

            BuildProperties_TEL(
                properties,
                card);

            BuildProperties_TITLE(
                properties,
                card);

            BuildProperties_TZ(
                properties,
                card);

            BuildProperties_UID(
                properties,
                card);

            BuildProperties_URL(
                properties,
                card);

            BuildProperties_X_WAB_GENDER(
                properties,
                card);

            // The end of the vCard is marked with an END:VCARD.

            properties.Add(new vCardProperty("END", "VCARD"));
            return(properties);
        }
Ejemplo n.º 20
0
        // The following functions export a vCard and then re-read it back
        // as a new vCard.  All fields and collections are compared to ensure
        // the full fidelity of the export/import process.

        #region [ CycleStandard ]

        public static void CycleStandard(vCard card)
        {
            CycleStandard21(card);
        }
Ejemplo n.º 21
0
        public void ReadWriteProperty_FamilyName()
        {
            
            // Make sure .FamilyName reads/writes

            vCard card = new vCard();
            card.FamilyName = "Tchaikovsky";

            Assert.AreEqual(
                "Tchaikovsky",
                card.FamilyName,
                "The FamilyName property does not return the same value written to it.");

        }
Ejemplo n.º 22
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);
                }
            }
        }
Ejemplo n.º 23
0
        public void StringEmpty_UniqueId()
        {

            vCard card = new vCard();

            Assert.IsEmpty(
                card.UniqueId,
                "UniqueId is not string.Empty.");

            card.UniqueId = null;

            Assert.IsEmpty(
                card.UniqueId,
                "UniqueId is not string.Empty after being assigned null.");

        }
Ejemplo n.º 24
0
        public void StringEmpty_Title()
        {

            vCard card = new vCard();

            Assert.IsEmpty(
                card.Title,
                "Title is not string.Empty.");

            card.Title = null;

            Assert.IsEmpty(
                card.Title,
                "Title is not string.Empty after being assigned null.");

        }
Ejemplo n.º 25
0
 /// <summary>
 ///     Reads vCard information from a text reader and
 ///     populates into an existing vCard object. [Deprecated]
 /// </summary>
 /// <param name="card">
 ///     An initialized vCard object.
 /// </param>
 /// <param name="reader">
 ///     A text reader containing vCard data in the format
 ///     expected by the card reader class.
 /// </param>
 public abstract void ReadInto(vCard card, TextReader reader);
Ejemplo n.º 26
0
        /// <summary>
        ///     Builds EMAIL properties.
        /// </summary>
        private void BuildProperties_EMAIL(
            vCardPropertyCollection properties,
            vCard card)
        {
            // The EMAIL property contains an electronic
            // mail address for the purpose.  A vCard may contain
            // as many email addresses as needed.  The format also
            // supports various vendors, such as CompuServe addresses
            // and Internet SMTP addresses.
            //
            // EMAIL;INTERNET:[email protected]

            foreach (vCardEmailAddress emailAddress in card.EmailAddresses)
            {
                vCardProperty property = new vCardProperty();
                property.Name  = "EMAIL";
                property.Value = emailAddress.Address;

                if (emailAddress.IsPreferred)
                {
                    property.Subproperties.Add("PREF");
                }

                switch (emailAddress.EmailType)
                {
                case vCardEmailAddressType.Internet:
                    property.Subproperties.Add("INTERNET");
                    break;

                case vCardEmailAddressType.AOL:
                    property.Subproperties.Add("AOL");
                    break;

                case vCardEmailAddressType.AppleLink:
                    property.Subproperties.Add("AppleLink");
                    break;

                case vCardEmailAddressType.AttMail:
                    property.Subproperties.Add("ATTMail");
                    break;

                case vCardEmailAddressType.CompuServe:
                    property.Subproperties.Add("CIS");
                    break;

                case vCardEmailAddressType.eWorld:
                    property.Subproperties.Add("eWorld");
                    break;

                case vCardEmailAddressType.IBMMail:
                    property.Subproperties.Add("IBMMail");
                    break;

                case vCardEmailAddressType.MCIMail:
                    property.Subproperties.Add("MCIMail");
                    break;

                case vCardEmailAddressType.PowerShare:
                    property.Subproperties.Add("POWERSHARE");
                    break;

                case vCardEmailAddressType.Prodigy:
                    property.Subproperties.Add("PRODIGY");
                    break;

                case vCardEmailAddressType.Telex:
                    property.Subproperties.Add("TLX");
                    break;

                case vCardEmailAddressType.X400:
                    property.Subproperties.Add("X400");
                    break;

                default:
                    property.Subproperties.Add("INTERNET");
                    break;
                }

                properties.Add(property);
            }
        }
Ejemplo n.º 27
0
        private void BuildProperties_PHOTO(
            vCardPropertyCollection properties,
            vCard card)
        {
            foreach (vCardPhoto photo in card.Photos)
            {
                if (photo.Url == null)
                {
                    // This photo does not have a URL associated
                    // with it.  Therefore a property can be
                    // generated only if the image data is loaded.
                    // Otherwise there is not enough information.

                    if (photo.IsLoaded)
                    {
                        properties.Add(
                            new vCardProperty("PHOTO", photo.GetBytes()));
                    }
                }
                else
                {
                    // This photo has a URL associated with it.  The
                    // PHOTO property can either be linked as an image
                    // or embedded, if desired.

                    bool doEmbedded =
                        photo.Url.IsFile ? this.embedLocalImages : this.embedInternetImages;

                    if (doEmbedded)
                    {
                        // According to the settings of the card writer,
                        // this linked image should be embedded into the
                        // vCard data.  Attempt to fetch the data.

                        try
                        {
                            photo.Fetch();
                        }
                        catch
                        {
                            // An error was encountered.  The image can
                            // still be written as a link, however.

                            doEmbedded = false;
                        }
                    }

                    // At this point, doEmbedded is true only if (a) the
                    // writer was configured to embed the image, and (b)
                    // the image was successfully downloaded.

                    if (doEmbedded)
                    {
                        properties.Add(
                            new vCardProperty("PHOTO", photo.GetBytes()));
                    }
                    else
                    {
                        vCardProperty uriPhotoProperty =
                            new vCardProperty("PHOTO");

                        // Set the VALUE property to indicate that
                        // the data for the photo is a URI.

                        uriPhotoProperty.Subproperties.Add("VALUE", "URI");
                        uriPhotoProperty.Value = photo.Url.ToString();

                        properties.Add(uriPhotoProperty);
                    }
                }
            }
        }
Ejemplo n.º 28
0
        /// <summary>
        ///     Builds TEL properties.
        /// </summary>
        private void BuildProperties_TEL(
            vCardPropertyCollection properties,
            vCard card)
        {
            // The TEL property indicates a telephone number of
            // the person (including non-voice numbers like fax
            // and BBS numbers).
            //
            // TEL;VOICE;WORK:1-800-929-5805

            foreach (vCardPhone phone in card.Phones)
            {
                // A telephone entry has the property name TEL and
                // can have zero or more subproperties like FAX
                // or HOME.  Examples:
                //
                //   TEL;HOME:+1-612-555-1212
                //   TEL;FAX;HOME:+1-612-555-1212

                vCardProperty property = new vCardProperty();

                property.Name = "TEL";

                if (phone.IsBBS)
                {
                    property.Subproperties.Add("BBS");
                }

                if (phone.IsCar)
                {
                    property.Subproperties.Add("CAR");
                }

                if (phone.IsCellular)
                {
                    property.Subproperties.Add("CELL");
                }

                if (phone.IsFax)
                {
                    property.Subproperties.Add("FAX");
                }

                if (phone.IsHome)
                {
                    property.Subproperties.Add("HOME");
                }

                if (phone.IsISDN)
                {
                    property.Subproperties.Add("ISDN");
                }

                if (phone.IsMessagingService)
                {
                    property.Subproperties.Add("MSG");
                }

                if (phone.IsModem)
                {
                    property.Subproperties.Add("MODEM");
                }

                if (phone.IsPager)
                {
                    property.Subproperties.Add("PAGER");
                }

                if (phone.IsPreferred)
                {
                    property.Subproperties.Add("PREF");
                }

                if (phone.IsVideo)
                {
                    property.Subproperties.Add("VIDEO");
                }

                if (phone.IsVoice)
                {
                    property.Subproperties.Add("VOICE");
                }

                if (phone.IsWork)
                {
                    property.Subproperties.Add("WORK");
                }

                property.Value = phone.FullNumber;
                properties.Add(property);
            }
        }
Ejemplo n.º 29
0
        private void _parseCard1(vCard card)
        {

            // 01 BEGIN:vCard
            // 02 VERSION:3.0
            // 03 FN:Frank Dawson
            // 04 ORG:Lotus Development Corporation
            // 05 ADR;TYPE=WORK,POSTAL,PARCEL:;;6544 Battleford Drive
            // 06  ;Raleigh;NC;27613-3502;U.S.A.
            // 07 TEL;TYPE=VOICE,MSG,WORK:+1-919-676-9515
            // 08 TEL;TYPE=FAX,WORK:+1-919-676-9564
            // 09 EMAIL;TYPE=INTERNET,PREF:[email protected]
            // 10 EMAIL;TYPE=INTERNET:[email protected]
            // 11 URL:http://home.earthlink.net/~fdawson
            // 12 END:vCard

            Assert.AreEqual(
                "Frank Dawson",
                card.FormattedName,
                "FN on line 3 is different.");

            Assert.AreEqual(
                "Lotus Development Corporation",
                card.Organization,
                "ORG on line 4 is different.");

            Assert.AreEqual(
                1,
                card.DeliveryAddresses.Count,
                "One address expected in card 1 at line 5.");

            // 05 ADR;TYPE=WORK,POSTAL,PARCEL:;;6544 Battleford Drive
            // 06  ;Raleigh;NC;27613-3502;U.S.A.

            Assert.IsTrue(
                card.DeliveryAddresses[0].IsWork,
                "ADR on lines 5-6 is a work address.");

            Assert.IsTrue(
                card.DeliveryAddresses[0].IsPostal,
                "ADR on lines 5-6 is a postal address.");

            Assert.IsTrue(
                card.DeliveryAddresses[0].IsParcel,
                "ADR on lines 5-6 is a parcel address.");

            Assert.AreEqual(
                "6544 Battleford Drive",
                card.DeliveryAddresses[0].Street,
                "ADR on lines 5-6 has a different street address.");

            Assert.AreEqual(
                "Raleigh",
                card.DeliveryAddresses[0].City,
                "ADR on lines 5-6 has a different city.");

            Assert.AreEqual(
                "27613-3502",
                card.DeliveryAddresses[0].PostalCode,
                "ADR on lines 5-6 has a different postal code.");

            Assert.AreEqual(
                "U.S.A.",
                card.DeliveryAddresses[0].Country,
                "ADR on lines 5-6 has a different country.");

            // 07 TEL;TYPE=VOICE,MSG,WORK:+1-919-676-9515
            // 08 TEL;TYPE=FAX,WORK:+1-919-676-9564

            Assert.AreEqual(
                2,
                card.Phones.Count,
                "Two phones are expected at lines 7-8.");

            Assert.IsTrue(
                card.Phones[0].IsVoice,
                "TEL at line 7 is a voice number.");

            Assert.IsTrue(
                card.Phones[0].IsMessagingService,
                "TEL at line 7 is a messaging service.");

            Assert.IsTrue(
                card.Phones[0].IsWork,
                "TEL at line 7 is a work number.");

            Assert.AreEqual(
                "+1-919-676-9515",
                card.Phones[0].FullNumber,
                "TEL at line 7 has a different number.");

            // 08 TEL;TYPE=FAX,WORK:+1-919-676-9564

            Assert.IsTrue(
                card.Phones[1].IsFax,
                "TEL at line 8 is a fax number.");

            Assert.IsTrue(
                card.Phones[1].IsWork,
                "TEL at line 8 is a work number.");

            Assert.AreEqual(
                "+1-919-676-9564",
                card.Phones[1].FullNumber,
                "TEL at line 8 has a different number.");

            // 09 EMAIL;TYPE=INTERNET,PREF:[email protected]
            // 10 EMAIL;TYPE=INTERNET:[email protected]

            Assert.AreEqual(
                2,
                card.EmailAddresses.Count,
                "Two email addresses are at lines 9 and 10.");

            Assert.IsTrue(
                card.EmailAddresses[0].EmailType == vCardEmailAddressType.Internet,
                "EMAIL at line 9 is an Internet email address.");

            Assert.IsTrue(
                card.EmailAddresses[0].IsPreferred,
                "EMAIL at line 9 is a preferred email address.");

            Assert.AreEqual(
                "*****@*****.**",
                card.EmailAddresses[0].Address,
                "EMAIL at line 9 has a different value.");

            // 10 EMAIL;TYPE=INTERNET:[email protected]

            Assert.AreEqual(
                vCardEmailAddressType.Internet,
                card.EmailAddresses[1].EmailType,
                "EMAIL at line 10 is an Internet email address.");

            Assert.AreEqual(
                "*****@*****.**",
                card.EmailAddresses[1].Address,
                "EMAIL at line 10 has a different value.");

            // 11 URL:http://home.earthlink.net/~fdawson

            Assert.AreEqual(
                1,
                card.Websites.Count,
                "One URL is located at line 11.");

            Assert.AreEqual(
                "http://home.earthlink.net/~fdawson",
                card.Websites[0].Url,
                "URL at line 11 has a different value.");

        }
Ejemplo n.º 30
0
        public override string Parse()
        {
            if (!File.Exists(Context.Path))
                throw new FileNotFoundException("File " + Context.Path + " is not found");

            string path = Context.Path;
            StringBuilder sb = new StringBuilder();
            using (StreamReader sr = new StreamReader(path))
            {
                while (!sr.EndOfStream)
                {
                    var card = new vCard(sr);

                    if (!string.IsNullOrEmpty(card.FormattedName))
                        sb.AppendFormat("[Full Name]{0}" + Environment.NewLine, card.FormattedName);
                    if (!string.IsNullOrEmpty(card.GivenName))
                        sb.AppendFormat("[First Name]{0}" + Environment.NewLine, card.GivenName);
                    if (!string.IsNullOrEmpty(card.AdditionalNames))
                        sb.AppendFormat("[Middle Name]{0}" + Environment.NewLine, card.AdditionalNames);
                    if (!string.IsNullOrEmpty(card.FamilyName))
                        sb.AppendFormat("[Last Name]{0}" + Environment.NewLine, card.FamilyName);
                    if (!string.IsNullOrEmpty(card.ProductId))
                        sb.AppendFormat("[Product ID]{0}" + Environment.NewLine, card.ProductId);
                    if (!string.IsNullOrEmpty(card.Organization))
                        sb.AppendFormat("[Orgnization]{0}" + Environment.NewLine, card.Organization);
                    if (card.Sources.Count > 0)
                    {
                        sb.AppendLine("[Sources]");
                        foreach (var vSource in card.Sources)
                        {
                            sb.AppendLine(vSource.Uri.OriginalString);
                        }
                    }
                    if (!string.IsNullOrEmpty(card.Title))
                        sb.AppendFormat("[Title]{0}" + Environment.NewLine, card.Title);
                    if (card.Gender != vCardGender.Unknown)
                        sb.AppendFormat("[Gender]{0}" + Environment.NewLine, card.Gender);
                    if (card.Nicknames.Count > 0)
                    {
                        sb.AppendFormat("[Nickname]{0}" + Environment.NewLine, card.Nicknames[0]);
                    }
                    if (card.DeliveryAddresses.Count > 0)
                    {
                        sb.AppendLine("[Addresses]");
                        foreach (var dAddr in card.DeliveryAddresses)
                        {
                            sb.Append(dAddr.AddressType + ":");
                            if (!string.IsNullOrEmpty(dAddr.Street))
                                sb.Append(dAddr.Street + ",");
                            if (!string.IsNullOrEmpty(dAddr.City))
                                sb.Append(dAddr.City + ",");
                            if (!string.IsNullOrEmpty(dAddr.Region))
                                sb.Append(dAddr.Region + ",");
                            if (!string.IsNullOrEmpty(dAddr.Country))
                                sb.Append(dAddr.Country + ",");

                            sb.AppendLine();
                        }
                    }
                    if (card.Phones.Count > 0)
                    {
                        sb.AppendLine("[Phones]");
                        foreach (var vphone in card.Phones)
                        {
                            sb.AppendFormat("{0}:{1}" + Environment.NewLine, vphone.PhoneType, vphone.FullNumber);
                        }
                    }
                    if (card.EmailAddresses.Count > 0)
                    {
                        sb.AppendLine("[Emails]");
                        foreach (var vEmail in card.EmailAddresses)
                        {
                            sb.AppendFormat("{0}:{1}" + Environment.NewLine, vEmail.EmailType, vEmail.Address);
                        }
                    }
                    if (card.Websites.Count > 0)
                    {
                        sb.AppendLine("[Websites]");
                        foreach (var vWebsite in card.Websites)
                        {
                            sb.AppendLine(vWebsite.Url);
                        }
                    }
                    sb.AppendLine();
                }
            }
            return sb.ToString();
        }
Ejemplo n.º 31
0
        public void StringEmpty_NameSuffix()
        {

            vCard card = new vCard();

            Assert.IsEmpty(
                card.NameSuffix,
                "NameSuffix is not string.Empty.");

            card.NameSuffix = null;

            Assert.IsEmpty(
                card.NameSuffix,
                "NameSuffix is not string.Empty after being assigned null.");

        }
Ejemplo n.º 32
0
        public void ParseOutlookSimple()
        {

            // 01 BEGIN:VCARD
            // 02 VERSION:2.1
            // 03 N:Pinch;David;John
            // 04 FN:David John Pinch
            // 05 NICKNAME:Dave
            // 06 ORG:Thought Project
            // 07 TITLE:Dictator
            // 08 TEL;WORK;VOICE:800-929-5805
            // 09 TEL;HOME;VOICE:612-269-6017
            // 10 ADR;HOME:;;129 15th Street #3;Minneapolis;MN;55403;United States of America
            // 11 LABEL;HOME;ENCODING=QUOTED-PRINTABLE:129 15th Street #3=0D=0AMinneapolis, MN 55403=0D=0AUnited States of America
            // 12 URL;WORK:http://www.thoughtproject.com
            // 13 EMAIL;PREF;INTERNET:[email protected]
            // 14 REV:20061130T234000Z
            // 15 END:VCARD

            vCard card = new vCard(
                new StreamReader(new MemoryStream(SampleCards.OutlookSimple)));

            // 03 N:Pinch;David;John

            Assert.AreEqual(
                "Pinch",
                card.FamilyName,
                "N at line 3 has a different family name.");

            Assert.AreEqual(
                "David",
                card.GivenName,
                "N at line 3 has a different given name.");

            Assert.AreEqual(
                "John",
                card.AdditionalNames,
                "N at line 3 has a different middle name.");

            // 04 FN:David John Pinch

            Assert.AreEqual(
                "David John Pinch",
                card.FormattedName,
                "FN at line 4 has a different formatted name.");

            // 05 NICKNAME:Dave

            Assert.AreEqual(
                1,
                card.Nicknames.Count,
                "Exactly one nickname is located at line 5.");

            Assert.AreEqual(
                "Dave",
                card.Nicknames[0],
                "NICKNAME at line 5 has a different value.");

            // 06 ORG:Thought Project

            Assert.AreEqual(
                "Thought Project",
                card.Organization,
                "ORG at line 6 has a different value.");

            // 07 TITLE:Dictator

            Assert.AreEqual(
                "Dictator",
                card.Title,
                "TITLE at line 7 has a different value.");

            // 08 TEL;WORK;VOICE:800-929-5805
            // 09 TEL;HOME;VOICE:612-269-6017

            Assert.AreEqual(
                2,
                card.Phones.Count,
                "Two telephone numbers are defined at lines 8 and 9.");

            Assert.IsTrue(
                card.Phones[0].IsWork,
                "TEL at line 8 is a work number.");

            Assert.IsTrue(
                card.Phones[0].IsVoice,
                "TEL at line 8 is a voice number.");

            Assert.AreEqual(
                "800-929-5805",
                card.Phones[0].FullNumber,
                "TEL at line 8 has a different value.");

            // 09 TEL;HOME;VOICE:612-269-6017

            Assert.IsTrue(
                card.Phones[1].IsHome,
                "TEL at line 9 is a home number.");

            Assert.IsTrue(
                card.Phones[1].IsVoice,
                "TEL at line 9 is a voice number.");

            Assert.AreEqual(
                "612-269-6017",
                card.Phones[1].FullNumber,
                "TEL at line 9 has a different value.");

            // 10 ADR;HOME:;;129 15th Street #3;Minneapolis;MN;55403;United States of America

            Assert.AreEqual(
                1,
                card.DeliveryAddresses.Count,
                "There is one delivery address at line 10.");

            Assert.AreEqual(
                "129 15th Street #3",
                card.DeliveryAddresses[0].Street,
                "ADR at line 10 has a different street.");

            Assert.AreEqual(
                "Minneapolis",
                card.DeliveryAddresses[0].City,
                "ADR at line 10 has a different city.");

            Assert.AreEqual(
                "MN",
                card.DeliveryAddresses[0].Region,
                "ADR at line 10 has a different region/state.");

            Assert.AreEqual(
                "55403",
                card.DeliveryAddresses[0].PostalCode,
                "ADR at line 10 has a different postal code.");

            Assert.AreEqual(
                "United States of America",
                card.DeliveryAddresses[0].Country,
                "ADR at line 10 has a different country.");

            // 11 LABEL;HOME;ENCODING=QUOTED-PRINTABLE:129 15th Street #3=0D=0AMinneapolis, MN 55403=0D=0AUnited States of America

            Assert.AreEqual(
                1,
                card.DeliveryLabels.Count,
                "There is one delivery label at line 11.");

            Assert.IsTrue(
                card.DeliveryLabels[0].IsHome,
                "LABEL at line 11 is a home delivery address.");

            Assert.AreEqual(
                "129 15th Street #3\r\nMinneapolis, MN 55403\r\nUnited States of America",
                card.DeliveryLabels[0].Text,
                "LABEL at line 11 has a different decoded value.");

            // 12 URL;WORK:http://www.thoughtproject.com

            Assert.AreEqual(
                1,
                card.Websites.Count,
                "There is one web site (URL) at line 12.");

            Assert.IsTrue(
                card.Websites[0].IsWorkSite,
                "The web site at line 12 is a work-related web site.");

            Assert.AreEqual(
                "http://www.thoughtproject.com",
                card.Websites[0].Url,
                "URL at line 12 has a different value.");

            // 13 EMAIL;PREF;INTERNET:[email protected]

            Assert.AreEqual(
                1,
                card.EmailAddresses.Count,
                "There is one email address at line 13.");

            Assert.IsTrue(
                card.EmailAddresses[0].IsPreferred,
                "The email address at line 13 is the preferred email address.");

            Assert.AreEqual(
                "*****@*****.**",
                card.EmailAddresses[0].Address,
                "EMAIL at line 13 has a different value.");

            // 14 REV:20061130T234000Z

            Assert.AreEqual(
                vCardStandardReader.ParseDate("20061130T234000Z").Value,
                card.RevisionDate.Value,
                "REV at line 14 has a different value.");


        }
Ejemplo n.º 33
0
        public void StringEmpty_Office()
        {

            vCard card = new vCard();

            Assert.IsEmpty(
                card.Office,
                "Office is not string.Empty.");

            card.Office = null;

            Assert.IsEmpty(
                card.Office,
                "Office is not string.Empty after being assigned null.");

        }
Ejemplo n.º 34
0
        public void ParseUnicodeSimple()
        {
            vCard card = new vCard(
               new StreamReader(new MemoryStream(SampleCards.UnicodeNameSample)));

            Assert.IsNotNull(card);
            //Assert.AreEqual("³ÂÀö¾ý", card.GivenName);
        }
Ejemplo n.º 35
0
        public void StringEmpty_Organization()
        {

            vCard card = new vCard();

            Assert.IsEmpty(
                card.Organization,
                "Organization is not string.Empty.");

            card.Organization = null;

            Assert.IsEmpty(
                card.Organization,
                "Organization is not string.Empty after being assigned null.");

        }
Ejemplo n.º 36
0
        public void ParseOutlookCertificate()
        {

            // 01 BEGIN:VCARD
            // 02 VERSION:2.1
            // 03 N:Pinch;David;John
            // 04 FN:David John Pinch
            // 05 NICKNAME:Dave
            // 06 ORG:Thought Project
            // 07 TITLE:Dictator
            // 08 TEL;WORK;VOICE:800-929-5805
            // 09 TEL;HOME;VOICE:612-269-6017
            // 10 KEY;X509;ENCODING=BASE64:
            // 11    MIICZDCCAc2gAwIBAgIQRMnJkySZCu8S15WhdyuljjANBgkqhkiG9w0BAQUFADBiMQswCQYD
            // 12   VQQGEwJaQTElMCMGA1UEChMcVGhhd3RlIENvbnN1bHRpbmcgKFB0eSkgTHRkLjEsMCoGA1UE
            // 13    AxMjVGhhd3RlIFBlcnNvbmFsIEZyZWVtYWlsIElzc3VpbmcgQ0EwHhcNMDcwNTExMTU0NTI2
            // 14    WhcNMDgwNTEwMTU0NTI2WjBJMR8wHQYDVQQDExZUaGF3dGUgRnJlZW1haWwgTWVtYmVyMSYw
            // 15    JAYJKoZIhvcNAQkBFhdkYXZlQHRob3VnaHRwcm9qZWN0LmNvbTCBnzANBgkqhkiG9w0BAQEF
            // 16    AAOBjQAwgYkCgYEAmLhq0UDsgB8paOBzXCtv9SbwccPYJhJr6f7bK3JO1xkCbKmzoLhCZUVB
            // 17    4zP5bWTBnQYpolA9t1Pbrd29flX90xizEljCuL2uOz4cFc+NoF7h0h5nFvnFVAmzsJmLnCop
            // 18    vp0GD4jy3cpQhBNAoSqQbwjSuqyFtHeVMIbNlU3Y/Y8CAwEAAaM0MDIwIgYDVR0RBBswGYEX
            // 19    ZGF2ZUB0aG91Z2h0cHJvamVjdC5jb20wDAYDVR0TAQH/BAIwADANBgkqhkiG9w0BAQUFAAOB
            // 20    gQCuMF4mUI5NWv0DqblQH/pqJN0eCjj2j4iQhJNTHtfhrS0ETbakgldJCzg5Rv+8V2Dil7gs
            // 21    4zMmwOuDrHVBqWDvF0/hXzMn5KKWEmzCZshVyFJ24IWkIj4t3wOMG21NdSA+zX7TEc3s7oWh
            // 22    zi6q4lcDj3pOzUyDmaEEBYcyWLKXpA==
            // 23
            // 24
            // 25 EMAIL;PREF;INTERNET:[email protected]
            // 26 REV:20070511T163814Z
            // 27 END:VCARD

            vCard card = new vCard(
                new StreamReader(new MemoryStream(SampleCards.OutlookCertificate)));

            // 03 N:Pinch;David;John

            Assert.AreEqual(
                "Pinch",
                card.FamilyName,
                "N at line 3 has a different family name.");

            Assert.AreEqual(
                "David",
                card.GivenName,
                "N at line 3 has a different given name.");

            Assert.AreEqual(
                "John",
                card.AdditionalNames,
                "N at line 3 has a different middle name.");

            Assert.AreEqual(
                1,
                card.Certificates.Count,
                "Only one certificate was expected.");

            // 04 FN:David John Pinch

            Assert.AreEqual(
                "David John Pinch",
                card.FormattedName,
                "FN at line 4 has a different formatted name.");

            // 05 NICKNAME:Dave

            Assert.AreEqual(
                1,
                card.Nicknames.Count,
                "Exactly one nickname is located at line 5.");

            Assert.AreEqual(
                "Dave",
                card.Nicknames[0],
                "NICKNAME at line 5 has a different value.");

            // 06 ORG:Thought Project

            Assert.AreEqual(
                "Thought Project",
                card.Organization,
                "ORG at line 6 has a different value.");

            // 07 TITLE:Dictator

            Assert.AreEqual(
                "Dictator",
                card.Title,
                "TITLE at line 7 has a different value.");

            // 08 TEL;WORK;VOICE:800-929-5805
            // 09 TEL;HOME;VOICE:612-269-6017

            Assert.AreEqual(
                2,
                card.Phones.Count,
                "Two telephone numbers are defined at lines 8 and 9.");

            Assert.IsTrue(
                card.Phones[0].IsWork,
                "TEL at line 8 is a work number.");

            Assert.IsTrue(
                card.Phones[0].IsVoice,
                "TEL at line 8 is a voice number.");

            Assert.AreEqual(
                "800-929-5805",
                card.Phones[0].FullNumber,
                "TEL at line 8 has a different value.");

            // 09 TEL;HOME;VOICE:612-269-6017

            Assert.IsTrue(
                card.Phones[1].IsHome,
                "TEL at line 9 is a home number.");

            Assert.IsTrue(
                card.Phones[1].IsVoice,
                "TEL at line 9 is a voice number.");

            Assert.AreEqual(
                "612-269-6017",
                card.Phones[1].FullNumber,
                "TEL at line 9 has a different value.");

            // 10 KEY;X509;ENCODING=BASE64:

            Assert.AreEqual(
                1,
                card.Certificates.Count,
                "There is one certificate starting on line 10.");

            Assert.AreEqual(
                "X509",
                card.Certificates[0].KeyType,
                "KEY on line 10 has a different key type.");

            // Create an instance of the certificate.

            X509Certificate2 cert =
                new X509Certificate2(card.Certificates[0].Data);

            Assert.AreEqual(
                KeyIssuer,
                cert.Issuer,
                "The key issuer has a different value.");

            Assert.AreEqual(
                KeySubject,
                cert.Subject,
                "The key subject has a different value.");


        }
 /// <summary>
 ///     Writes a vCard to an I/O stream using the format
 ///     implemented by the class.
 /// </summary>
 /// <param name="card">
 ///     The vCard to write the I/O string.
 /// </param>
 /// <param name="output">
 ///     The text writer to use for output.
 /// </param>
 /// <remarks>
 ///     The implementor should not close or flush the stream.
 ///     The caller owns the stream and may not wish for the
 ///     stream to be closed (e.g. the caller may call the
 ///     function again with a different vCard).
 /// </remarks>
 public abstract void Write(vCard card, TextWriter output);