/// <summary> /// Initializes a new instance of the <see cref="vCard"/> class. /// </summary> public vCard() { // Per Microsoft best practices, string properties should // never return null. String properties should always // return String.Empty. this.additionalNames = string.Empty; this.department = string.Empty; this.displayName = string.Empty; this.familyName = string.Empty; this.formattedName = string.Empty; this.givenName = string.Empty; this.mailer = string.Empty; this.namePrefix = string.Empty; this.nameSuffix = string.Empty; this.office = string.Empty; this.organization = string.Empty; this.productId = string.Empty; this.role = string.Empty; this.timeZone = string.Empty; this.title = string.Empty; this.uniqueId = string.Empty; this.categories = new List <string>(); this.certificates = new vCardCertificateCollection(); this.deliveryAddresses = new vCardDeliveryAddressCollection(); this.deliveryLabels = new vCardDeliveryLabelCollection(); this.emailAddresses = new vCardEmailAddressCollection(); this.nicknames = new List <string>(); this.notes = new vCardNoteCollection(); this.phones = new vCardPhoneCollection(); this.photos = new vCardPhotoCollection(); this.sources = new vCardSourceCollection(); this.websites = new vCardWebsiteCollection(); }
private void CheckAddress(vCardDeliveryAddressCollection addresses, string street, string city, string state, string zip, string country, vCardDeliveryAddressTypes addressTypes, bool isPreferred) { //there is no street address 2 it is just separated with \n if (addresses == null || addresses.Count == 0) { Assert.Fail("addresses null or empty"); } var a = addresses.FirstOrDefault(x => x.Street == street && x.City == city); Assert.IsNotNull(a); Assert.AreEqual(state, a.Region); Assert.AreEqual(zip, a.PostalCode); Assert.AreEqual(country, a.Country); foreach (var adr in a.AddressType.Where(x => x != vCardDeliveryAddressTypes.Preferred)) { Assert.IsTrue(adr.HasFlag(addressTypes), "address types are not equal"); } // Assert.AreEqual(addressTypes, a.AddressType.); Assert.AreEqual(isPreferred, a.IsPreferred); Assert.AreEqual(a.IsPreferred, a.AddressType.Any(x => x.HasFlag(vCardDeliveryAddressTypes.Preferred))); }
/// <summary> /// Initializes a new instance of the <see cref="vCard"/> class. /// </summary> public vCard() { // Per Microsoft best practices, string properties should // never return null. String properties should always // return String.Empty. additionalNames = string.Empty; department = string.Empty; displayName = string.Empty; familyName = string.Empty; formattedName = string.Empty; givenName = string.Empty; mailer = string.Empty; namePrefix = string.Empty; nameSuffix = string.Empty; office = string.Empty; organization = string.Empty; productId = string.Empty; role = string.Empty; timeZone = string.Empty; title = string.Empty; uniqueId = string.Empty; categories = new StringCollection(); certificates = new vCardCertificateCollection(); deliveryAddresses = new vCardDeliveryAddressCollection(); deliveryLabels = new vCardDeliveryLabelCollection(); emailAddresses = new vCardEmailAddressCollection(); nicknames = new StringCollection(); notes = new vCardNoteCollection(); phones = new vCardPhoneCollection(); photos = new vCardPhotoCollection(); sources = new vCardSourceCollection(); websites = new vCardWebsiteCollection(); }
public static void Equals( vCardDeliveryAddressCollection dac1, vCardDeliveryAddressCollection dac2) { Assert.AreEqual( dac1.Count, dac2.Count, "The two delivery address collections differ."); for (int index = 0; index < dac1.Count; index++) { Equals(dac1[index], dac2[index]); } }
private void SetAddressesValues(vCardDeliveryAddressCollection addresses) { ClearAddressTextFields(); if (addresses.Any()) { var HomeAddress = addresses.Where(x => x.IsHome).FirstOrDefault(); if (HomeAddress != null) { HomeAddressValue.Text = HomeAddress.Street; HomeCityValue.Text = HomeAddress.City; HomeZipValue.Text = HomeAddress.PostalCode; HomeStateValue.Text = HomeAddress.Region; HomeCountryValue.Text = HomeAddress.Country; } var WorkAddress = addresses.Where(x => x.IsWork).FirstOrDefault(); if (WorkAddress != null) { WorkAddressValue.Text = WorkAddress.Street; WorkCityValue.Text = WorkAddress.City; WorkZipValue.Text = WorkAddress.PostalCode; WorkStateValue.Text = WorkAddress.Region; WorkCountryValue.Text = WorkAddress.Country; } var PostalAddress = addresses.Where(x => x.IsPostal).FirstOrDefault(); if (PostalAddress != null) { PostalAddressValue.Text = PostalAddress.Street; PostalAddressValue.Text = PostalAddress.Street; PostalCityValue.Text = PostalAddress.City; PostalZipValue.Text = PostalAddress.PostalCode; PostalStateValue.Text = PostalAddress.Region; PostalCountryValue.Text = PostalAddress.Country; } } }
/// <summary> /// Initializes a new instance of the <see cref="vCard"/> class. /// </summary> public vCard() { // Per Microsoft best practices, string properties should // never return null. String properties should always // return String.Empty. this.additionalNames = string.Empty; this.department = string.Empty; this.displayName = string.Empty; this.familyName = string.Empty; this.formattedName = string.Empty; this.givenName = string.Empty; this.mailer = string.Empty; this.namePrefix = string.Empty; this.nameSuffix = string.Empty; this.office = string.Empty; this.organization = string.Empty; this.productId = string.Empty; this.role = string.Empty; this.timeZone = string.Empty; this.title = string.Empty; this.uniqueId = string.Empty; this.categories = new StringCollection(); this.certificates = new vCardCertificateCollection(); this.deliveryAddresses = new vCardDeliveryAddressCollection(); this.deliveryLabels = new vCardDeliveryLabelCollection(); this.emailAddresses = new vCardEmailAddressCollection(); this.nicknames = new StringCollection(); this.notes = new vCardNoteCollection(); this.phones = new vCardPhoneCollection(); this.photos = new vCardPhotoCollection(); this.sources = new vCardSourceCollection(); this.websites = new vCardWebsiteCollection(); this.ims = new vCardIMPPCollection(); this.sps = new vCardSocialProfileCollection(); }
writer.Write(c, sw); sw.Flush(); text = sw.ToString(); sw.Close(); } Assert.IsNotNull(text); } } private void CheckSocialProfile(vCardSocialProfileCollection sps, string username, string url, SocialProfileServiceType serviceType) { if (sps == null || sps.Count == 0) {
/// <summary> /// Parses a vCard contact /// </summary> /// <param name="vCard"></param> /// <returns></returns> private static Contact ParseVCard(vCard vCard) { Contact contact = new Contact(false); contact.ID = vCard.UniqueId; if (contact.ID == string.Empty) { contact.ID = IDGenerator.GenerateID(); } #region Name { Name name = Name.TryParse(vCard.FormattedName); if (name == null) { name = new Name(); } if (vCard.GivenName != string.Empty) { name.FirstName = vCard.GivenName; } if (vCard.AdditionalNames != string.Empty) { name.MiddleName = vCard.AdditionalNames; } if (vCard.FamilyName != string.Empty) { name.LastName = vCard.FamilyName; } if (vCard.NamePrefix != string.Empty) { name.Title = vCard.NamePrefix; } if (vCard.NameSuffix != string.Empty) { name.Suffix = vCard.NameSuffix; } contact.Name = name; } #endregion #region Delivery Address { vCardDeliveryAddressCollection vAddresses = vCard.DeliveryAddresses; int count = vAddresses.Count; Address[] addresses = new Address[count]; for (int i = 0; i < count; i++) { vCardDeliveryAddress vAddress = vAddresses[i]; Address address = new Address(); address.City = vAddress.City; address.Country = vAddress.Country; address.State = vAddress.Region; address.Street = vAddress.Street.TrimEnd(','); address.ZIP = vAddress.PostalCode; address.Type = vAddress.AddressType.ToString(); addresses[i] = address; } contact.Addresses = addresses; } #endregion #region Email Address { vCardEmailAddressCollection vEmails = vCard.EmailAddresses; int count = vEmails.Count; Email[] emails = new Email[count]; for (int i = 0; i < count; i++) { vCardEmailAddress vEmail = vEmails[i]; Email email = new Email(); email.Address = vEmail.Address; email.Type = vEmail.EmailType.ToString(); emails[i] = email; } contact.Emails = emails; } #endregion #region Website { vCardWebsiteCollection vWebsites = vCard.Websites; int count = vWebsites.Count; Website[] websites = new Website[count]; for (int i = 0; i < count; i++) { vCardWebsite vWebsite = vWebsites[i]; Website website = new Website(); website.Url = vWebsite.Url; website.Type = vWebsite.WebsiteType.ToString(); websites[i] = website; } contact.Websites = websites; } #endregion #region Notes { FlowDocument notes = new FlowDocument(); foreach (vCardNote each in vCard.Notes) { Paragraph para = new Paragraph(new Run(each.Text)); if (each.Language != string.Empty) { try { para.Language = XmlLanguage.GetLanguage(each.Language); } catch { } } notes.Blocks.Add(para); } contact.NotesDocument = notes; } #endregion #region Phone { vCardPhoneCollection vPhones = vCard.Phones; int count = vPhones.Count; PhoneNumber[] phones = new PhoneNumber[count]; for (int i = 0; i < count; i++) { vCardPhone vPhone = vPhones[i]; PhoneNumber phone = new PhoneNumber(); phone.Number = vPhone.FullNumber; phone.Type = InsertSpaces(vPhone.PhoneType.ToString()); phones[i] = phone; } contact.PhoneNumbers = phones; } #endregion if (vCard.BirthDate.HasValue) { contact.SpecialDates = new SpecialDate[] { new SpecialDate("Birthday", vCard.BirthDate.Value) } } ; contact.Private = vCard.AccessClassification.HasFlag(vCardAccessClassification.Confidential) || vCard.AccessClassification.HasFlag(vCardAccessClassification.Private); contact.Work = new Work() { Company = vCard.Organization, Department = vCard.Department, Office = vCard.Office, Title = vCard.Title }; contact.Gender = (Gender)vCard.Gender; if (vCard.IMAddress != string.Empty) { contact.IM = new IM[] { new IM("IM", vCard.IMAddress) } } ; foreach (vCardPhoto photo in vCard.Photos) { if (photo.Url != null) { try { photo.Fetch(); contact.encodeTile(photo.GetBytes()); //contact.Tile = Create96By96Tile(ConvertBytesToBitmapSource(photo.GetBytes())); break; } catch { } } else { contact.encodeTile(photo.GetBytes()); //contact.Tile = Create96By96Tile(ConvertBytesToBitmapSource(photo.GetBytes())); break; } } return(contact); }