public void EncodeProperty_Null() { vCardStandardWriter writer = new vCardStandardWriter(); writer.EncodeProperty(null); }
public CardDavRepository(ICardDavDataAccess cardDavDataAccess, bool writeImAsImpp) : base(cardDavDataAccess) { _vCardStandardWriter = new vCardStandardWriter() { WriteImAsImpp = writeImAsImpp }; }
/// <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); }
public CardDavRepository(ICardDavDataAccess cardDavDataAccess, bool writeImAsImpp, IEqualityComparer <string> versionComparer) : base(cardDavDataAccess, versionComparer) { _vCardStandardWriter = new vCardStandardWriter() { WriteImAsImpp = writeImAsImpp }; }
public void SamplevCardReadAndWriteTestWithPhotos() { string base64Photo = @"/9j/4AAQSkZJRgABAQEAYABgAAD/2wBDAAYEBQYFBAYGBQYHBwYIChAKCgkJChQODwwQFxQY GBcUFhYaHSUfGhsjHBYWICwgIyYnKSopGR8tMC0oMCUoKSj/2wBDAQcHBwoIChMKChMoGhYa KCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCj/wAAR CAA3AEgDASIAAhEBAxEB/8QAHwAAAQUBAQEBAQEAAAAAAAAAAAECAwQFBgcICQoL/8QAtRAA AgEDAwIEAwUFBAQAAAF9AQIDAAQRBRIhMUEGE1FhByJxFDKBkaEII0KxwRVS0fAkM2JyggkK FhcYGRolJicoKSo0NTY3ODk6Q0RFRkdISUpTV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P9Fn/wCup/kKjEJKyRzu9ncS5XBo pNUYxwyMvUDiiiEbo53ubgIrN8QQefp8oVBIVG7Yeje1Le38VlA007YRRn3P0rzjVviBfS3c kNrEkEe7ardWx/Ku2VCc37oUW07ot6FaLaSQ3ESnyZTnawwV7YNev6Jqun2nhq6eWKBJVjOD gDJxXik+tui20wybdkCvj+Fh1qGXUDrV59ne5ZbZV+VVPDH3FctWk+bU9mnW5Vdnufwq8S6X cm6tbqeNwxDqG6bhnp74r5d8R3sVzr+oz2/+rluJHQexY4r0AJpunaN9os3PmF9nQjBxya8+ uNEfzA0dxEQ3IzxWtKHIr9DKtUU5PubnwzzLr7Z52wk/yFev6EmLSf8A66n+Qryz4c2Mmn6p cTXDJtaMKCpz1I/wr1bQmBs5COhkJrLEatHFOVmylrp227+/FFQeIXOFUHqaK0pR905Wzh9Z 1P8AtdWmZiVUYxyB9MVw2ptJDqLM2MqR09+9FFe7XSVNWN6as7HU+CZI7u9u7C5BZJcSLnse 9dLF8OWursHS7sQSMeFcZX/61FFeRXk4zdjqi/dOWuGkhlnspHDCCZ4zjoSDg4/nV/wJNC+t xW91Ek0UoZGV1yMjoR+VFFdc4r2TXkYSep2euafZ6ftlsrdY95+YLxnFa+iOY9MUHqSTRRXl PWKMZtsyNal3Tge1FFFdtKK5UZM//9k="; vCard card = new vCard(); card.EmailAddresses.Add(new vCardEmailAddress() { Address = "*****@*****.**", EmailType = vCardEmailAddressType.Internet, IsPreferred = true, ItemType = ItemType.WORK }); card.Photos.Add(new vCardPhoto(base64Photo, true)); 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); }
public void EncodeProperty_Null() { vCardStandardWriter writer = new vCardStandardWriter(); Assert.Throws <ArgumentNullException>(() => writer.EncodeProperty(null)); }
public void EncodeEscaped_Semicolon_CRLF() { vCardStandardWriter writer = new vCardStandardWriter(); Assert.AreEqual( @"\;\r\n", writer.EncodeEscaped(";\r\n")); }
public void EncodeEscaped_Comma_Text_Comma() { vCardStandardWriter writer = new vCardStandardWriter(); Assert.AreEqual( @"\,text\,", writer.EncodeEscaped(",text,")); }
public void EncodeEscaped_Semicolon_Space_Semicolon() { vCardStandardWriter writer = new vCardStandardWriter(); Assert.AreEqual( @"\; \;", writer.EncodeEscaped("; ;")); }
public void EncodeEscaped_CRLF_Text() { vCardStandardWriter writer = new vCardStandardWriter(); Assert.AreEqual( @"\r\ntext", writer.EncodeEscaped("\r\ntext")); }
public void EncodeEscaped_Null() { vCardStandardWriter writer = new vCardStandardWriter(); Assert.AreEqual( null, writer.EncodeEscaped((string)null)); }
public void EncodeEscaped_Empty() { vCardStandardWriter writer = new vCardStandardWriter(); Assert.AreEqual( string.Empty, writer.EncodeEscaped(string.Empty)); }
/// <summary> /// Generate a VCard class from a string. /// </summary> /// <param name="card"></param> /// <returns></returns> private string generateRawContent(vCard card) { vCardStandardWriter writer = new vCardStandardWriter(); TextWriter tw = new StringWriter(); writer.Write(card, tw); return(tw.ToString()); }
public static string FixNote(string vcardData, vCardStandardWriter writer) { // Reformat NOTE attribute since quoted-printable is deprecated var noteMatch = Regex.Match(vcardData, "NOTE;ENCODING=QUOTED-PRINTABLE:(.*?)\r\n"); if (noteMatch.Success) { string decodedNote = vCardStandardReader.DecodeQuotedPrintable(noteMatch.Groups[1].Value).Replace("\r\n", "\n"); return(Regex.Replace(vcardData, "NOTE;ENCODING=QUOTED-PRINTABLE:(.*?)\r\n", writer.EncodeEscaped("NOTE:" + decodedNote) + "\r\n")); } return(vcardData); }
/// <summary> /// Convert the ContactData instance into a vCard for the payload of this record. /// </summary> private void AssemblePayload() { var vCard = ConvertContactToVCard(ContactData); var vcWriter = new vCardStandardWriter(); var ms = new MemoryStream(); var writer = new StreamWriter(ms); vcWriter.Write(vCard, writer); writer.Flush(); Payload = ms.ToArray(); }
public void EncodeProperty_Name_Value() { vCardStandardWriter writer = new vCardStandardWriter(); vCardProperty property = new vCardProperty("NAME", "VALUE"); Assert.AreEqual( "NAME:VALUE", writer.EncodeProperty(property)); }
public void EncodeProperty_Name_Subproperty_Subvalue_Value() { vCardStandardWriter writer = new vCardStandardWriter(); vCardProperty property = new vCardProperty("NAME", "VALUE"); property.Subproperties.Add("SUB", "SUBVALUE"); Assert.AreEqual( "NAME;SUB=SUBVALUE:VALUE", writer.EncodeProperty(property)); }
public void EncodeProperty_Name_Subproperty() { vCardStandardWriter writer = new vCardStandardWriter(); vCardProperty property = new vCardProperty("NAME"); property.Subproperties.Add("SUB"); Assert.AreEqual( "NAME;SUB:", writer.EncodeProperty(property)); }
public void SaveAs(string path) { if (this.cards == null || this.cards.Count == 0) { throw new InvalidDataException("No data to be saved"); } vCardStandardWriter writer = new vCardStandardWriter(); using (TextWriter tw = File.CreateText(path)) { foreach (var card in this.cards) { writer.Write(card.ToVCard(), tw); } } }
public IActionResult GetVCard(string fullName) { var emp = list.FirstOrDefault(x => x.FullName == fullName); var vCard = new vCard(); vCard.Title = emp.Title; vCard.FormattedName = fullName; vCardStandardWriter wrt = new vCardStandardWriter(); StringWriter sw = new StringWriter(); // Specify charset to encode non-ascii strings. Use Western-European // encoding in this sample (you can also use UTF-8 or whatever). wrt.Write(vCard, sw, "UTF-8"); return(File(Encoding.GetEncoding("UTF-8").GetBytes(sw.ToString()), "application/octet-stream", "info.vcf")); }
public virtual void SaveToFile() { fileName = this.DisplayName;//key: set file name for vCard. if (!Directory.Exists(rootPath)) { Directory.CreateDirectory(rootPath); } string path = rootPath + Path.DirectorySeparatorChar + fileName + ".vcf"; //saving vCard vCardStandardWriter writer = new vCardStandardWriter(); writer.EmbedInternetImages = false; writer.EmbedLocalImages = true; writer.Options = vCardStandardWriterOptions.IgnoreCommas; writer.Write(this as vCard, path); }
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); } }
static void Main(string[] args) { // Generate vCard vCard vCard = new vCard(); vCard.GivenName = "Forrest"; vCard.FamilyName = "Gump"; vCard.Organization = "Bubba Gump Shrimp Co."; vCard.Title = "Shrimp Man"; vCard.Phones.Add(new vCardPhone("(111) 555-1212", vCardPhoneTypes.Home)); vCard.EmailAddresses.Add(new vCardEmailAddress("*****@*****.**", vCardEmailAddressType.Internet)); vCardDeliveryAddress address = new vCardDeliveryAddress(); address.AddressType = vCardDeliveryAddressTypes.Home; address.Street = "100 Waters Edge"; address.City = "Baytown"; address.Region = "LA"; address.PostalCode = "30314"; address.Country = "United States of America"; vCard.DeliveryAddresses.Add(address); // Save vCard data to string vCardStandardWriter writer = new vCardStandardWriter(); StringWriter stringWriter = new StringWriter(); writer.Write(vCard, stringWriter); // Create Bytescout.Barcode instance using (Barcode barcode = new Barcode()) { // Set barcode type barcode.Symbology = SymbologyType.QRCode; // Set barcode value barcode.Value = stringWriter.ToString(); // Save barcode to image barcode.SaveImage("result.png", ImageFormat.Png); // Open generated barcode image in default associated application Process.Start("result.png"); } }
protected void createButton_Click(object sender, EventArgs e) { vCard card = new vCard(); // Simple properties //card.AdditionalNames = AdditionalNames.Text; card.FamilyName = this.familyNameBox.Text; card.FormattedName = this.formattedNameBox.Text; card.GivenName = this.givenNameBox.Text; //card.NamePrefix = NamePrefix.Text; //card.NameSuffix = NameSuffix.Text; card.Organization = this.organizationTextBox.Text; //card.Role = Role.Text; card.Title = this.titleTextBox.Text; // --------------------------------------------------------------- // Email Addresses // --------------------------------------------------------------- // A vCard supports any number of email addresses. if (!string.IsNullOrEmpty(this.workEmailBox.Text)) { card.EmailAddresses.Add( new vCardEmailAddress(this.workEmailBox.Text)); } // --------------------------------------------------------------- // Nicknames // --------------------------------------------------------------- string[] nicklist = this.nicknamesBox.Text.Split(new char[] { ',' }); foreach (string nick in nicklist) { if (nick.Length > 0) card.Nicknames.Add(nick); } // --------------------------------------------------------------- // Notes // --------------------------------------------------------------- // The vCard specification allows for multiple notes, although // most applications seem to support a maximum of one note. //if (Note.Text.Length > 0) //{ // card.Notes.Add(new vCardNote(Note.Text)); //} // --------------------------------------------------------------- // Phones // --------------------------------------------------------------- // // A vCard supports any number of telephones. Each telephone can // have a different type (such as a video phone or a fax) and a // purpose (e.g. a home number or a work number). //if (!string.IsNullOrEmpty(WorkPhone.Text)) //{ // card.Phones.Add( // new vCardPhone(WorkPhone.Text, vCardPhoneTypes.WorkVoice)); //} //if (!string.IsNullOrEmpty(WorkFax.Text)) //{ // card.Phones.Add( // new vCardPhone(WorkFax.Text, vCardPhoneTypes.WorkFax)); //} // --------------------------------------------------------------- // Web Sites // --------------------------------------------------------------- //if (WorkWebSite.Text.Length > 0) //{ // card.Websites.Add( // new vCardWebsite(WorkWebSite.Text, vCardWebsiteTypes.Work)); //} // The vCard object has been populated. The rest of // the code generates the vCard file format and exports // it to the response stream. Response.ContentType = "text/x-vcard"; // The "content-disposition" is a special HTTP header // that tells the web browser how to interpreted the // output. In this case, the browser is informed the // content should be treated as an attachment with // a default filename. This should cause the browser // to display a dialog box to save the vCard (instead // of displaying the vCard as inline text). Response.AppendHeader( "content-disposition", "attachment;filename=vCard.vcf"); vCardStandardWriter writer = new vCardStandardWriter(); writer.EmbedInternetImages = false; writer.EmbedLocalImages = true; writer.Options = vCardStandardWriterOptions.IgnoreCommas; writer.Write(card, Response.Output); Response.End(); }
private byte[] GeneratevCard(Person person, string site) { // create the card var vCard = new vCard(); // name information vCard.FamilyName = person.LastName; vCard.GivenName = person.FirstName; vCard.NamePrefix = person.Salutation; // job information vCard.Organization = person.GetLatestRegistration(site).Firm.Name; vCard.Title = person.GetLatestRegistration(site).Title; // picture if (person.MainProfilePicture != null) { vCard.Photos.Add(new vCardPhoto(person.MainProfilePicture)); } // add contact information based on authorization if (person.ContactInformationRelease) { // contact information vCard.EmailAddresses.Add(new vCardEmailAddress(person.User.UserName)); // business address only var busAddr = person.Addresses.Where(a => a.AddressType.Id.ToString() == StaticIndexes.Address_Business).FirstOrDefault(); if (busAddr != null) { var addr = new vCardDeliveryAddress() { AddressType = vCardDeliveryAddressTypes.Work, City = busAddr.City, Country = busAddr.Country.Name, IsWork = true, PostalCode = busAddr.Zip, Street = string.Format("{0} {1}", busAddr.Line1, busAddr.Line2 ?? string.Empty), Region = busAddr.State }; vCard.DeliveryAddresses.Add(addr); } } // prepare the writer to write the vcard output var writer = new vCardStandardWriter(); writer.EmbedInternetImages = false; writer.EmbedLocalImages = true; writer.Options = vCardStandardWriterOptions.IgnoreCommas; // put the data into a memory stream var stream = new MemoryStream(); var streamWriter = new StreamWriter(stream); // write the data to the stream writer.Write(vCard, streamWriter); // write to the memory stream streamWriter.Flush(); streamWriter.Close(); var bytes = stream.ToArray(); return(bytes); }
protected void createButton_Click(object sender, EventArgs e) { vCard card = new vCard(); // Simple properties //card.AdditionalNames = AdditionalNames.Text; card.FamilyName = this.familyNameBox.Text; card.FormattedName = this.formattedNameBox.Text; card.GivenName = this.givenNameBox.Text; //card.NamePrefix = NamePrefix.Text; //card.NameSuffix = NameSuffix.Text; card.Organization = this.organizationTextBox.Text; //card.Role = Role.Text; card.Title = this.titleTextBox.Text; // --------------------------------------------------------------- // Email Addresses // --------------------------------------------------------------- // A vCard supports any number of email addresses. if (!string.IsNullOrEmpty(this.workEmailBox.Text)) { card.EmailAddresses.Add( new vCardEmailAddress(this.workEmailBox.Text)); } // --------------------------------------------------------------- // Nicknames // --------------------------------------------------------------- string[] nicklist = this.nicknamesBox.Text.Split(new char[] { ',' }); foreach (string nick in nicklist) { if (nick.Length > 0) { card.Nicknames.Add(nick); } } // --------------------------------------------------------------- // Notes // --------------------------------------------------------------- // The vCard specification allows for multiple notes, although // most applications seem to support a maximum of one note. //if (Note.Text.Length > 0) //{ // card.Notes.Add(new vCardNote(Note.Text)); //} // --------------------------------------------------------------- // Phones // --------------------------------------------------------------- // // A vCard supports any number of telephones. Each telephone can // have a different type (such as a video phone or a fax) and a // purpose (e.g. a home number or a work number). //if (!string.IsNullOrEmpty(WorkPhone.Text)) //{ // card.Phones.Add( // new vCardPhone(WorkPhone.Text, vCardPhoneTypes.WorkVoice)); //} //if (!string.IsNullOrEmpty(WorkFax.Text)) //{ // card.Phones.Add( // new vCardPhone(WorkFax.Text, vCardPhoneTypes.WorkFax)); //} // --------------------------------------------------------------- // Web Sites // --------------------------------------------------------------- //if (WorkWebSite.Text.Length > 0) //{ // card.Websites.Add( // new vCardWebsite(WorkWebSite.Text, vCardWebsiteTypes.Work)); //} // The vCard object has been populated. The rest of // the code generates the vCard file format and exports // it to the response stream. Response.ContentType = "text/x-vcard"; // The "content-disposition" is a special HTTP header // that tells the web browser how to interpreted the // output. In this case, the browser is informed the // content should be treated as an attachment with // a default filename. This should cause the browser // to display a dialog box to save the vCard (instead // of displaying the vCard as inline text). Response.AppendHeader( "content-disposition", "attachment;filename=vCard.vcf"); vCardStandardWriter writer = new vCardStandardWriter(); writer.EmbedInternetImages = false; writer.EmbedLocalImages = true; writer.Options = vCardStandardWriterOptions.IgnoreCommas; writer.Write(card, Response.Output); Response.End(); }
public CardDavRepository(ICardDavDataAccess cardDavDataAccess, IChunkedExecutor chunkedExecutor) : base(cardDavDataAccess, chunkedExecutor) { _vCardStandardWriter = new vCardStandardWriter(); }
public void ShouldReadvCardWithAllCBFieldsFilledOutFromiPhoneNAB() { string text = @"BEGIN:VCARD VERSION:3.0 PRODID:-//Apple Inc.//iOS 6.0.1//EN N:iOS;Nic;;; FN:Nic iOS ORG:Ibm; TITLE:Sales Guy item1.EMAIL;type=INTERNET;type=pref:[email protected] EMAIL;type=INTERNET;type=WORK:[email protected] EMAIL;type=INTERNET;type=WORK:[email protected] EMAIL;type=INTERNET;type=HOME:[email protected] EMAIL;type=INTERNET;type=HOME:[email protected] TEL;type=CELL;type=VOICE;type=pref:(202) 333-4555 TEL;type=IPHONE;type=CELL;type=VOICE:(202) 333-4444 TEL;type=HOME;type=VOICE:(333) 222-2222 TEL;type=WORK;type=VOICE:(809) 555-6666 x444 TEL;type=MAIN:(609) 888-7777 TEL;type=HOME;type=FAX:(555) 444-4443 TEL;type=WORK;type=FAX:33322222222 item2.TEL:(999) 777-7999 item2.X-ABLabel:personal item3.ADR;type=HOME;type=pref:;;8230 Boone Blvd;Vinna;VA;22182;United States item3.X-ABADR:us item4.URL;type=pref:http://facebook.com/max.solender item4.X-ABLabel:Profile item5.URL:www.ibm.com item5.X-ABLabel:_$!<HomePage>!$_ item6.X-MSN:msnname item6.X-ABLabel:_$!<Other>!$_ item7.X-AIM:aolname item7.X-ABLabel:_$!<Other>!$_ item8.X-YAHOO:yahooname item8.X-ABLabel:_$!<Other>!$_ item9.X-JABBER:jabbername item9.X-ABLabel:_$!<Other>!$_ IMPP;X-SERVICE-TYPE=Skype;type=HOME;type=pref:skype:skypeusernameee IMPP;X-SERVICE-TYPE=Skype;type=WORK:skype:worksyokeusername item10.IMPP;X-SERVICE-TYPE=MSN:msnim:msnname item10.X-ABLabel:_$!<Other>!$_ item11.IMPP;X-SERVICE-TYPE=AIM:aim:aolname item11.X-ABLabel:_$!<Other>!$_ item12.IMPP;X-SERVICE-TYPE=GoogleTalk:xmpp:gtalkname item12.X-ABLabel:_$!<Other>!$_ item13.IMPP;X-SERVICE-TYPE=Yahoo:ymsgr:yahooname item13.X-ABLabel:_$!<Other>!$_ item14.IMPP;X-SERVICE-TYPE=Facebook:xmpp:fbchatname item14.X-ABLabel:_$!<Other>!$_ item15.IMPP;X-SERVICE-TYPE=Jabber:xmpp:jabbername item15.X-ABLabel:_$!<Other>!$_ item16.IMPP;X-SERVICE-TYPE=GaduGadu;type=HOME;type=pref:x-apple:jdgadu X-SOCIALPROFILE;type=linkedin;x-user=nicatlinkedin:http://www.linkedin.com/in/nicatlinkedin X-SOCIALPROFILE;type=twitter;x-user=tiffanystone:http://twitter.com/tiffanystone X-SOCIALPROFILE;type=facebook;x-user=tiffatfacebook:http://www.facebook.com/tiffatfacebook X-SOCIALPROFILE;type=twitter;x-user=gregabedard:http://twitter.com/gregabedard PHOTO;TYPE=JPEG;ENCODING=BASE64: /9j/4AAQSkZJRgABAQEAYABgAAD/2wBDAAYEBQYFBAYGBQYHBwYIChAKCgkJChQODwwQFxQY GBcUFhYaHSUfGhsjHBYWICwgIyYnKSopGR8tMC0oMCUoKSj/2wBDAQcHBwoIChMKChMoGhYa KCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCj/wAAR CAA3AEgDASIAAhEBAxEB/8QAHwAAAQUBAQEBAQEAAAAAAAAAAAECAwQFBgcICQoL/8QAtRAA AgEDAwIEAwUFBAQAAAF9AQIDAAQRBRIhMUEGE1FhByJxFDKBkaEII0KxwRVS0fAkM2JyggkK FhcYGRolJicoKSo0NTY3ODk6Q0RFRkdISUpTVFVWV1hZWmNkZWZnaGlqc3R1dnd4eXqDhIWG h4iJipKTlJWWl5iZmqKjpKWmp6ipqrKztLW2t7i5usLDxMXGx8jJytLT1NXW19jZ2uHi4+Tl 5ufo6erx8vP09fb3+Pn6/8QAHwEAAwEBAQEBAQEBAQAAAAAAAAECAwQFBgcICQoL/8QAtREA AgECBAQDBAcFBAQAAQJ3AAECAxEEBSExBhJBUQdhcRMiMoEIFEKRobHBCSMz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X cm6tbqeNwxDqG6bhnp74r5d8R3sVzr+oz2/+rluJHQexY4r0AJpunaN9os3PmF9nQjBxya8+ uNEfzA0dxEQ3IzxWtKHIr9DKtUU5PubnwzzLr7Z52wk/yFev6EmLSf8A66n+Qryz4c2Mmn6p cTXDJtaMKCpz1I/wr1bQmBs5COhkJrLEatHFOVmylrp227+/FFQeIXOFUHqaK0pR905Wzh9Z 1P8AtdWmZiVUYxyB9MVw2ptJDqLM2MqR09+9FFe7XSVNWN6as7HU+CZI7u9u7C5BZJcSLnse 9dLF8OWursHS7sQSMeFcZX/61FFeRXk4zdjqi/dOWuGkhlnspHDCCZ4zjoSDg4/nV/wJNC+t xW91Ek0UoZGV1yMjoR+VFFdc4r2TXkYSep2euafZ6ftlsrdY95+YLxnFa+iOY9MUHqSTRRXl PWKMZtsyNal3Tge1FFFdtKK5UZM//9k= END:VCARD"; vCardStandardReader reader = new vCardStandardReader(); using (StringReader sr = new StringReader(text)) { vCard c = reader.Read(sr); Assert.AreEqual(5, c.EmailAddresses.Count); CheckEmail(c.EmailAddresses, "*****@*****.**", ItemType.UNSPECIFIED, vCardEmailAddressType.Internet, true); CheckEmail(c.EmailAddresses, "*****@*****.**", ItemType.WORK, vCardEmailAddressType.Internet, false); CheckEmail(c.EmailAddresses, "*****@*****.**", ItemType.WORK, vCardEmailAddressType.Internet, false); CheckEmail(c.EmailAddresses, "*****@*****.**", ItemType.HOME, vCardEmailAddressType.Internet, false); CheckEmail(c.EmailAddresses, "*****@*****.**", ItemType.HOME, vCardEmailAddressType.Internet, false); Assert.AreEqual("Sales Guy", c.Title); Assert.AreEqual("Ibm", c.Organization); Assert.AreEqual("Nic", c.GivenName); Assert.AreEqual("iOS", c.FamilyName); Assert.AreEqual(8, c.Phones.Count); CheckPhone(c.Phones, "(202) 333-4555", vCardPhoneTypes.Preferred | vCardPhoneTypes.Cellular | vCardPhoneTypes.Voice, true); CheckPhone(c.Phones, "(202) 333-4444", vCardPhoneTypes.IPhone | vCardPhoneTypes.Cellular | vCardPhoneTypes.Voice, false); CheckPhone(c.Phones, "(333) 222-2222", vCardPhoneTypes.Home | vCardPhoneTypes.Voice, false); CheckPhone(c.Phones, "(809) 555-6666 x444", vCardPhoneTypes.Work | vCardPhoneTypes.Voice, false); CheckPhone(c.Phones, "(609) 888-7777", vCardPhoneTypes.Main, false); CheckPhone(c.Phones, "(555) 444-4443", vCardPhoneTypes.Home | vCardPhoneTypes.Fax, false); CheckPhone(c.Phones, "33322222222", vCardPhoneTypes.Work | vCardPhoneTypes.Fax, false); CheckPhone(c.Phones, "(999) 777-7999", vCardPhoneTypes.Default, false); //phones and emails are good //need to check the physical address parsing and on down CheckAddress(c.DeliveryAddresses, "8230 Boone Blvd", "Vinna", "VA", "22182", "United States", vCardDeliveryAddressTypes.Preferred & vCardDeliveryAddressTypes.Home, true); CheckIM(c.IMs, "skypeusernameee", IMServiceType.Skype, ItemType.HOME, true); CheckIM(c.IMs, "worksyokeusername", IMServiceType.Skype, ItemType.WORK, false); CheckIM(c.IMs, "msnname", IMServiceType.MSN, ItemType.UNSPECIFIED, false); CheckIM(c.IMs, "aolname", IMServiceType.AIM, ItemType.UNSPECIFIED, false); CheckIM(c.IMs, "gtalkname", IMServiceType.GoogleTalk, ItemType.UNSPECIFIED, false); CheckIM(c.IMs, "yahooname", IMServiceType.Yahoo, ItemType.UNSPECIFIED, false); CheckIM(c.IMs, "fbchatname", IMServiceType.Facebook, ItemType.UNSPECIFIED, false); CheckIM(c.IMs, "jabbername", IMServiceType.Jabber, ItemType.UNSPECIFIED, false); CheckIM(c.IMs, "jdgadu", IMServiceType.GaduGadu, ItemType.HOME, true); Assert.AreEqual(4, c.SocialProfiles.Count); CheckSocialProfile(c.SocialProfiles, "nicatlinkedin", "http://www.linkedin.com/in/nicatlinkedin", SocialProfileServiceType.LinkedIn); CheckSocialProfile(c.SocialProfiles, "tiffanystone", "http://twitter.com/tiffanystone", SocialProfileServiceType.Twitter); CheckSocialProfile(c.SocialProfiles, "tiffatfacebook", "http://www.facebook.com/tiffatfacebook", SocialProfileServiceType.Facebook); CheckSocialProfile(c.SocialProfiles, "gregabedard", "http://twitter.com/gregabedard", SocialProfileServiceType.Twitter); Assert.AreEqual(1, c.Photos.Count); var photo = c.Photos.First(); Assert.IsFalse(photo.HasEncodedData, "encoded data should is true"); var encodedString = photo.EncodedData; Assert.IsTrue(string.IsNullOrEmpty(encodedString), "encoded data is empty"); System.Drawing.Bitmap bitmap = photo.GetBitmap(); Assert.IsNotNull(bitmap); //temp quickly vCardStandardWriter writer = new vCardStandardWriter(); using (StringWriter sw = new StringWriter()) { writer.Write(c, sw); sw.Flush(); text = sw.ToString(); sw.Close(); } Assert.IsNotNull(text); } }
public void SamlevCardReadAndWriteTestWithContentFromWikipedia() { string text = @"BEGIN:VCARD VERSION:3.0 N:Gump;Forrest FN:Forrest Gump ORG:Bubba Gump Shrimp Co. TITLE:Shrimp Man PHOTO;VALUE=URL;TYPE=GIF:http://www.example.com/dir_photos/my_photo.gif TEL;TYPE=WORK,VOICE:(111) 555-1212 TEL;TYPE=HOME,VOICE:(404) 555-1212 ADR;TYPE=WORK;type=pref:;;100 Waters Edge;Baytown;LA;30314;United States of America EMAIL;TYPE=PREF,INTERNET:[email protected] REV:2008-04-24T19:52:43Z END:VCARD"; //ADR;TYPE=HOME:;;42 Plantation St.;Baytown;LA;30314;United States of America //LABEL;TYPE=HOME:42 Plantation St.\nBaytown, LA 30314\nUnited States of America 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.UNSPECIFIED, email.ItemType); Assert.AreEqual(vCardEmailAddressType.Internet, email.EmailType); Assert.AreEqual("*****@*****.**", email.Address); Assert.AreEqual("Shrimp Man", cardFromReader.Title); Assert.AreEqual("Forrest", cardFromReader.GivenName); Assert.AreEqual("Gump", cardFromReader.FamilyName); Assert.AreEqual(2, cardFromReader.Phones.Count); var phone404 = cardFromReader.Phones.FirstOrDefault(x => x.FullNumber == "(404) 555-1212"); var phone111 = cardFromReader.Phones.FirstOrDefault(x => x.FullNumber == "(111) 555-1212"); Assert.IsNotNull(phone111); Assert.IsNotNull(phone404); Assert.IsTrue(phone111.IsWork); Assert.IsTrue(phone111.IsVoice); Assert.IsTrue(phone404.IsVoice); Assert.IsTrue(phone404.IsHome); Assert.AreEqual(1, cardFromReader.DeliveryAddresses.Count); var address = cardFromReader.DeliveryAddresses.First(); Assert.IsNotNull(address); Assert.IsTrue(address.AddressType.Any(a => a == vCardDeliveryAddressTypes.Work), "work address type not found"); Assert.IsTrue(address.AddressType.Any(a => a == vCardDeliveryAddressTypes.Preferred), "preferred address type not found"); vCardStandardWriter standardWriter = new vCardStandardWriter(); using (StringWriter sw = new StringWriter()) { standardWriter.Write(cardFromReader, sw); sw.Flush(); var tempStrign = sw.ToString(); Assert.IsNotNull(tempStrign); } } //need to add social Profile types as property to the vCard object and reader/writer //need to try and add a bunch of properties in my ipad NAB and email me a .vcf file //then generate via my parser and try and import the VCF into my ipad //look at creating nuGet package for deploying the bin / dll }
public void UT_vCardLibTest() { vCard card = new vCard(); // Simple properties //card.AdditionalNames = AdditionalNames.Text; card.FamilyName = "刘"; card.FormattedName = "刘杨"; card.GivenName = "杨"; //card.NamePrefix = NamePrefix.Text; //card.NameSuffix = NameSuffix.Text; card.Organization = "微软"; //card.Role = Role.Text; card.Title = "高级研发经理"; // --------------------------------------------------------------- // Email Addresses // --------------------------------------------------------------- // A vCard supports any number of email addresses. //card.EmailAddresses.Add( // new vCardEmailAddress("浦驰路 1809弄 104号 701")); // --------------------------------------------------------------- // Nicknames // --------------------------------------------------------------- //string[] nicklist = new string[] { "泡沫刘" }; //foreach (string nick in nicklist) //{ // if (nick.Length > 0) // card.Nicknames.Add(nick); //} // --------------------------------------------------------------- // Notes // --------------------------------------------------------------- // The vCard specification allows for multiple notes, although // most applications seem to support a maximum of one note. //if (Note.Text.Length > 0) //{ // card.Notes.Add(new vCardNote(Note.Text)); //} // --------------------------------------------------------------- // Phones // --------------------------------------------------------------- // // A vCard supports any number of telephones. Each telephone can // have a different type (such as a video phone or a fax) and a // purpose (e.g. a home number or a work number). //if (!string.IsNullOrEmpty(WorkPhone.Text)) //{ // card.Phones.Add( // new vCardPhone(WorkPhone.Text, vCardPhoneTypes.WorkVoice)); //} card.Phones.Add( new vCardPhone("13681765654", vCardPhoneTypes.Cellular)); //if (!string.IsNullOrEmpty(WorkFax.Text)) //{ // card.Phones.Add( // new vCardPhone(WorkFax.Text, vCardPhoneTypes.WorkFax)); //} // --------------------------------------------------------------- // Web Sites // --------------------------------------------------------------- //if (WorkWebSite.Text.Length > 0) //{ // card.Websites.Add( // new vCardWebsite(WorkWebSite.Text, vCardWebsiteTypes.Work)); //} var writer = new vCardStandardWriter(); writer.EmbedInternetImages = false; writer.EmbedLocalImages = true; writer.Options = vCardStandardWriterOptions.IgnoreCommas; StringBuilder sb = new StringBuilder(); using (var textWriter = new StringWriter(sb)) { writer.Write(card, textWriter); } var expected = @"BEGIN:VCARD N:刘;杨;;; FN:刘杨 ORG:微软 TEL;CELL:13681765654 TITLE:高级研发经理 END:VCARD "; Assert.AreEqual(expected, sb.ToString()); }
public CardDavRepository(ICardDavDataAccess cardDavDataAccess) { _cardDavDataAccess = cardDavDataAccess; _vCardWriter = new vCardStandardWriter(); }