public static AddressCollection ParseAddresses(String toAddresses) { /*[email protected], "Simpson Marge" <*****@*****.**>, * "Simpson Bart" <*****@*****.**>, , "Simpson Bart" <*****@*****.**>, * "Simpson Maggie" <*****@*****.**>, */ String recipientName, line; String[] inlineRecipients; ActiveUp.Net.Mail.AddressCollection addresses = new AddressCollection(); toAddresses = toAddresses.Replace("<", String.Empty); toAddresses = toAddresses.Replace(">", String.Empty); String[] recipients = toAddresses.Split(new String[] { ",", ";" }, StringSplitOptions.RemoveEmptyEntries); foreach (String recipientLine in recipients) { line = recipientLine; if (recipientLine.Contains("\"")) { recipientName = recipientLine.Substring(recipientLine.IndexOf("\"") + 1, recipientLine.LastIndexOf("\"") - recipientLine.IndexOf("\"") - 1); line = recipientLine.Remove(0, recipientLine.LastIndexOf("\"") + 1); } else { recipientName = ""; } line = System.Text.RegularExpressions.Regex.Replace(line, @"\s+", " "); inlineRecipients = line.Split(new String[] { " " }, StringSplitOptions.RemoveEmptyEntries); for (Int16 currentInlineRecipient = 0; currentInlineRecipient < inlineRecipients.Length; currentInlineRecipient++) { if (inlineRecipients[currentInlineRecipient] == " " || inlineRecipients[currentInlineRecipient] == "\"" || inlineRecipients[currentInlineRecipient] == ":") { continue; } if (currentInlineRecipient == 0 && recipientName != "") { addresses.Add(new ActiveUp.Net.Mail.Address(inlineRecipients[currentInlineRecipient], recipientName)); } else { addresses.Add(new ActiveUp.Net.Mail.Address(inlineRecipients[currentInlineRecipient])); } } } return(addresses); }
public AddressCollection GetAddressesDynamicCollection(string whereExpression, string orderBy) { IDBManager dbm = new DBManager(); AddressCollection cols = new AddressCollection(); try { dbm.CreateParameters(2); dbm.AddParameters(0, "@WhereCondition", whereExpression); dbm.AddParameters(1, "@OrderByExpression", orderBy); IDataReader reader = dbm.ExecuteReader(CommandType.StoredProcedure, "SelectAddressesDynamic"); while (reader.Read()) { Address address = new Address(); address.AddressID = Int32.Parse(reader["AddressID"].ToString()); address.AddressLine1 = reader["AddressLine1"].ToString(); address.AddressLine2 = reader["AddressLine2"].ToString(); address.City = reader["City"].ToString(); address.StateProvince = reader["StateProvince"].ToString(); address.PostalCode = reader["PostalCode"].ToString(); address.ModifiedDate = DateTime.Parse(reader["ModifiedDate"].ToString()); cols.Add(address); } } catch (Exception ex) { log.Write(ex.Message, "GetAddressesDynamicCollection"); throw (ex); } finally { dbm.Dispose(); } return(cols); }
public AddressCollection GetAllAddressesCollection() { IDBManager dbm = new DBManager(); AddressCollection cols = new AddressCollection(); try { IDataReader reader = dbm.ExecuteReader(CommandType.StoredProcedure, "SelectAddressesAll"); while (reader.Read()) { Address address = new Address(); address.AddressID = Int32.Parse(reader["AddressID"].ToString()); address.AddressLine1 = reader["AddressLine1"].ToString(); address.AddressLine2 = reader["AddressLine2"].ToString(); address.City = reader["City"].ToString(); address.StateProvince = reader["StateProvince"].ToString(); address.PostalCode = reader["PostalCode"].ToString(); address.ModifiedDate = DateTime.Parse(reader["ModifiedDate"].ToString()); cols.Add(address); } } catch (Exception ex) { log.Write(ex.Message, "GetAllAddressesCollection"); throw (ex); } finally { dbm.Dispose(); } return(cols); }
/// <summary Get Collection> /// Get collection of emails. If no records to return, EmailCollection will be null. /// </summary> /// <returns></returns> public static AddressCollection GetCollection(int employeeId) { AddressCollection tempList = null; using (SqlConnection myConnection = new SqlConnection(AppConfiguration.ConnectionString)) { using (SqlCommand myCommand = new SqlCommand("usp_GetAddress", myConnection)) { myCommand.CommandType = CommandType.StoredProcedure; myCommand.Parameters.AddWithValue("@QueryId", SelectTypeEnum.GetCollection); myCommand.Parameters.AddWithValue("@EmployeeId", employeeId); myConnection.Open(); using (SqlDataReader myReader = myCommand.ExecuteReader()) { if (myReader.HasRows) { tempList = new AddressCollection(); while (myReader.Read()) { tempList.Add(FillDataRecord(myReader)); } } myReader.Close(); } } } return tempList; }
public void Add(AddressBookRecord addressBookRecord) { if (!AddressCollection.Contains(addressBookRecord, AddressBookRecordComparer)) { AddressCollection.Add(addressBookRecord); } }
public void SaveMailContacts(int tenant, string user, Message message) { try { Func <AddressCollection, AddressCollection> copyAddressesFunc = delegate(AddressCollection addresses) { var newAddresses = new AddressCollection(); foreach (var address in addresses) { newAddresses.Add(new Address(address.Email, !string.IsNullOrEmpty(address.Name) ? Codec.RFC2047Decode(address.Name) : string.Empty)); } return(newAddresses); }; var contacts = new AddressCollection(); contacts.AddRange(copyAddressesFunc(message.To)); contacts.AddRange(copyAddressesFunc(message.Cc)); contacts.AddRange(copyAddressesFunc(message.Bcc)); var contactsList = contacts.Distinct().ToList(); using (var db = GetDb()) { var validContacts = (from contact in contactsList where MailContactExists(db, tenant, user, contact.Name, contact.Email) < 1 select contact).ToList(); if (!validContacts.Any()) { return; } var lastModified = DateTime.UtcNow; var insertQuery = new SqlInsert(ContactsTable.name) .InColumns(ContactsTable.Columns.id_user, ContactsTable.Columns.id_tenant, ContactsTable.Columns.name, ContactsTable.Columns.address, ContactsTable.Columns.last_modified); validContacts .ForEach(contact => insertQuery .Values(user, tenant, contact.Name, contact.Email, lastModified)); db.ExecuteNonQuery(insertQuery); } } catch (Exception e) { _log.Error("SaveMailContacts(tenant={0}, userId='{1}', mail_id={2}) Exception:\r\n{3}\r\n", tenant, user, message.Id, e.ToString()); } }
private AddressCollection MimeMessageToAddessCollectionGet(MimeMessage message) { var result = new AddressCollection(); foreach (var rawAddress in _testContext.MimeMessageToAddresses) { result.Add(new Address(rawAddress)); } return(result); }
public void InsertAndRemove() { Assert.DoesNotThrow(delegate { Address address = new Address(); AddressCollection addressCollection = new AddressCollection(); addressCollection.Add(address); address = addressCollection[0]; addressCollection[0] = address; addressCollection.Remove(address); }); }
protected void DataGrid_Update(object sender, DataGridCommandEventArgs e) { int index = grid.EditItemIndex; if (index >= addresses.Count) { addresses.Add("", ""); } Address address = addresses[index]; address.AddressLines.Clear(); DataGridItem item = grid.Items[index]; string[] addressLine = new string[5] { ((TextBox)item.FindControl("address0")).Text, ((TextBox)item.FindControl("address1")).Text, ((TextBox)item.FindControl("address2")).Text, ((TextBox)item.FindControl("address3")).Text, ((TextBox)item.FindControl("address4")).Text }; for (int i = 0; i < 5; i++) { if (!Utility.StringEmpty(addressLine[i])) { address.AddressLines.Add(addressLine[i]); } } address.UseType = ((TextBox)item.FindControl("useType")).Text; business.Save(); grid.EditItemIndex = -1; CancelEditMode(); PopulateDataGrid(); }
private void _bFilterEmails_Click(object sender, EventArgs e) { // We instantiate the pop3 client. Pop3Client pop = new Pop3Client(); try { this.AddLogEntry(string.Format("Connection to the pop 3 server : {0}", _tbPop3Server.Text)); // Connect to the pop3 client pop.Connect(_tbPop3Server.Text, _tbUserName.Text, _tbPassword.Text); AddressCollection ac; HeaderCollection hc = new HeaderCollection(); //Retrive a message headers for (int n = 1; n < pop.MessageCount + 1; n++) { Header h = pop.RetrieveHeaderObject(n); ac = new AddressCollection(); ac.Add(h.From); ac = Validator.Filter(ac); //If address is not filtered if (ac.Count > 0) { hc.Add(h); } } this.AddLogEntry(string.Format(" {0} messages passed the filter", hc.Count.ToString())); } catch (Pop3Exception pexp) { this.AddLogEntry(string.Format("Pop3 Error: {0}", pexp.Message)); } catch (Exception ex) { this.AddLogEntry(string.Format("Failed: {0}", ex.Message)); } finally { if (pop.IsConnected) { pop.Disconnect(); } } }
public void EXP_Send_Mail_Loads_Data_And_Sends_Mail_Correctly() { AddressCollection recipients = new AddressCollection(); AddressCollection BCC = new AddressCollection(); AddressCollection CC = new AddressCollection(); Address addressOne = new Address("*****@*****.**", "Simpson Marge"); Address addressSecond = new Address("*****@*****.**", "Simpson Bart"); Address addressThird = new Address("*****@*****.**", "Simpson Maggie"); recipients.Add(addressOne); recipients.Add(addressSecond); BCC.Add(addressOne); BCC.Add(addressThird); CC.Add(addressSecond); CC.Add(addressThird); String body = "<b>Body text here is bold.</b><div><br></div><div style=\"text-align: center;\">Body text here is centered.</div><div><br></div><div><font color=\"#ac193d\">Body text here is red.</font></div>"; String subject = "Glimpse Sender Test"; this.mySender.sendMail(recipients, body, subject, CC, BCC); Assert.Pass(); }
public void Enviar() { ServerCollection servers = new ServerCollection(); Server Nlayer = new Server(); Message message = new Message(); MimeBody mimeBody = new MimeBody(BodyFormat.Html); AddressCollection destinos = new AddressCollection(); Nlayer.Host = "mail.softwareNlayer.com"; Nlayer.Password = "******"; Nlayer.Port = 25; Nlayer.Username = "******"; servers.Add(Nlayer); if (_destinos != null) { foreach (string destino in _destinos) { destinos.Add(new Address(destino)); } } if (_adjuntos != null) { foreach (string adjunto in _adjuntos) { message.Attachments.Add(adjunto, false); } } mimeBody.Text = _mensaje; message.BodyHtml = mimeBody; message.Date = DateTime.Now; message.From = new Address("*****@*****.**"); message.Organization = "Nlayer Software"; message.Priority = MessagePriority.Normal; message.To = destinos; message.Subject = _asunto; AsyncCallback beginCallback = IniciaEnvio; SmtpClient.BeginSend(message, servers, beginCallback); }
protected AddressCollection getAllowedBillingAddresses(Customer customer) { AddressCollection addresses = new AddressCollection(); if (customer == null) { return(addresses); } foreach (Address address in customer.BillingAddresses) { Country country = address.Country; if (country != null && country.AllowsBilling) { addresses.Add(address); } } return(addresses); }
protected AddressCollection GetAllowedShippingAddresses(Customer customer) { var addresses = new AddressCollection(); if (customer == null) { return(addresses); } foreach (var address in customer.ShippingAddresses) { var country = address.Country; if (country != null && country.AllowsShipping) { addresses.Add(address); } } return(addresses); }
public static void SendGreetingsPassword(User newUser, String mailAddress) { SmtpMessage greetingsMail = new SmtpMessage(); AddressCollection to = new AddressCollection(); IList <MailAccount> userMailAccounts = newUser.GetAccounts(); #region Build Mail Body String mailBody = ""; mailBody += "¡Bienvenido a Glimpse!\nSu nuevo usuario es: " + newUser.Entity.Username + " (" + newUser.Entity.Firstname + " " + newUser.Entity.Lastname + ").\n" + "Las cuentas asociadas al mismo son:\n\n"; foreach (MailAccount userMailAccount in userMailAccounts) { mailBody += "\t- " + userMailAccount.Entity.Address; if (userMailAccount.Entity.IsMainAccount) { mailBody += " (cuenta principal)"; } mailBody += ".\n"; } mailBody += "\nPara editar la información de su usuario, ingrese a Glimpse y vaya al panel de Configuración.\n\n" + "Si no se ha registrado en Glimpse, por favor ignore este mensaje o responda al mismo indicando el inconveniente originado."; #endregion greetingsMail.From = new ActiveUp.Net.Mail.Address("*****@*****.**"); greetingsMail.BodyText.Text = mailBody; SetMailBodyEncoding(greetingsMail.BodyText, BodyFormat.Text); String encodedSubject = "=?ISO-8859-1?B?"; Encoding iso = Encoding.GetEncoding("ISO-8859-1"); encodedSubject += Convert.ToBase64String(iso.GetBytes("¡Bienvenido a Glimpse!"), Base64FormattingOptions.InsertLineBreaks); encodedSubject += "?="; greetingsMail.Subject = encodedSubject; to.Add(new ActiveUp.Net.Mail.Address(mailAddress)); greetingsMail.To = to; greetingsMail.SendSsl("smtp.gmail.com", 465, "*****@*****.**", "poiewq123890", SaslMechanism.Login); }
public static void SendResetPasswordMail(String username, String mailAddress, String newPassword) { SmtpMessage resetMail = new SmtpMessage(); AddressCollection to = new AddressCollection(); resetMail.From = new ActiveUp.Net.Mail.Address("*****@*****.**"); resetMail.BodyText.Text = "Usted ha olvidado la contraseña de su usuario Glimpse: " + username + ".\nLa nueva contraseña autogenerada es: \"" + newPassword + "\"." + "\nDeberá ingresar con ésta clave la próxima vez que ingrese a Glimpse."; SetMailBodyEncoding(resetMail.BodyText, BodyFormat.Text); String encodedSubject = "=?ISO-8859-1?B?"; Encoding iso = Encoding.GetEncoding("ISO-8859-1"); encodedSubject += Convert.ToBase64String(iso.GetBytes("Nueva Contraseña Glimpse"), Base64FormattingOptions.InsertLineBreaks); encodedSubject += "?="; resetMail.Subject = encodedSubject; to.Add(new ActiveUp.Net.Mail.Address(mailAddress)); resetMail.To = to; resetMail.SendSsl("smtp.gmail.com", 465, "*****@*****.**", "poiewq123890", SaslMechanism.Login); }
protected AddressCollection getAllowedShippingAddresses(Customer customer) { AddressCollection addresses = new AddressCollection(); if (customer == null) return addresses; foreach (Address address in customer.ShippingAddresses) { Country country = address.Country; if (country != null && country.AllowsShipping) { addresses.Add(address); } } return addresses; }
/// <summary> /// Parses a string containing addresses in the following formats : /// <list type="circle"> /// <item>"John Doe" <[email protected]>,"Mike Johns" <[email protected]></item> /// <item>"John Doe" <[email protected]>;"Mike Johns" <[email protected]></item> /// <item><[email protected]></item> /// <item>[email protected]</item> /// </list> /// </summary> /// <param name="input">A string containing addresses in the formats desribed above.</param> /// <returns>An AddressCollection object containing the parsed addresses.</returns> public static AddressCollection ParseAddresses(string input) { //TODO: enforce parser to use regex AddressCollection addresses = new AddressCollection(); string[] comma_separated = input.Split(','); for (int i = 0; i < comma_separated.Length; i++) if (comma_separated[i].IndexOf("@") == -1 && comma_separated.Length > (i + 1)) comma_separated[i + 1] = comma_separated[i] + comma_separated[i + 1]; for (int i = 0; i < comma_separated.Length; i++) if(comma_separated[i].IndexOf("@")!=-1) addresses.Add(Parser.ParseAddress((comma_separated[i].IndexOf("<") != -1 && comma_separated[i].IndexOf(":") != -1 && comma_separated[i].IndexOf(":") < comma_separated[i].IndexOf("<")) ? ((comma_separated[i].Split(':')[0].IndexOf("\"") == -1) ? comma_separated[i].Split(':')[1] : comma_separated[i]) : comma_separated[i])); //MatchCollection matches = Regex.Matches(input, "(\"(?<name>.+?)\")*\\s*<?(?<email>[^<>,\"\\s]+)>?"); //foreach (Match m in matches) // addresses.Add(m.Groups["email"].Value, m.Groups["name"].Value); return addresses; }
public static bool TryParseAddresses(string input, out AddressCollection addresses) { addresses = new AddressCollection(); try { var comma_separated = input.Split(','); for (var i = 0; i < comma_separated.Length; i++) if (comma_separated[i].IndexOf("@", StringComparison.Ordinal) == -1 && comma_separated.Length > (i + 1)) comma_separated[i + 1] = comma_separated[i] + comma_separated[i + 1]; foreach (var t in comma_separated.Where(t => t.IndexOf("@", StringComparison.Ordinal) != -1)) { var address_string = ( t.IndexOf("<", StringComparison.Ordinal) != -1 && t.IndexOf(":", StringComparison.Ordinal) != -1 && t.IndexOf(":", StringComparison.Ordinal) < t.IndexOf("<", StringComparison.Ordinal) ? ((t.Split(':')[0].IndexOf("\"", StringComparison.Ordinal) == -1) ? t.Split(':')[1] : t) : t); Address address; if (TryParseAddress(address_string, out address)) { addresses.Add(address); } } return true; } catch { } return false; }
/// <summary> /// Parses a string containing addresses in the following formats : /// <list type="circle"> /// <item>"John Doe" <[email protected]>,"Mike Johns" <[email protected]></item> /// <item>"John Doe" <[email protected]>;"Mike Johns" <[email protected]></item> /// <item><[email protected]></item> /// <item>[email protected]</item> /// </list> /// </summary> /// <param name="input">A string containing addresses in the formats desribed above.</param> /// <returns>An AddressCollection object containing the parsed addresses.</returns> public static AddressCollection ParseAddresses(string input) { //TODO: enforce parser to use regex var addresses = new AddressCollection(); var comma_separated = input.Split(','); for (var i = 0; i < comma_separated.Length; i++) if (comma_separated[i].IndexOf("@", StringComparison.Ordinal) == -1 && comma_separated.Length > (i + 1)) comma_separated[i + 1] = comma_separated[i] + comma_separated[i + 1]; foreach (var t in comma_separated.Where(t => t.IndexOf("@", StringComparison.Ordinal)!=-1)) addresses.Add( ParseAddress(( t.IndexOf("<", StringComparison.Ordinal) != -1 && t.IndexOf(":", StringComparison.Ordinal) != -1 && t.IndexOf(":", StringComparison.Ordinal) < t.IndexOf("<", StringComparison.Ordinal)) ? ((t.Split(':')[0].IndexOf("\"", StringComparison.Ordinal) == -1) ? t.Split(':')[1] : t) : t)); return addresses; }
public void StoreAddresses() { var collection = new AddressCollection(); var publicAddress = new Address("1ky1eHUrRR1kxKTbfiCptao9V25W97gDm"); var publicDetails = new AddressDetails(publicAddress, "public"); var miningAddress = new Address("1digVweRyrR9NbPaQJ2dfudXcZWQd81au"); var miningDetails = new AddressDetails(miningAddress, "mining"); var miscAddress = new Address("12pa32rAF8dejmKnU6XfXZ3aNCmroVNSQj"); var miscDetails = new AddressDetails(miscAddress); collection.Add(publicDetails); collection.Add(miningDetails); collection.Add(miscAddress); Assert.AreEqual(collection.Count, 3); Assert.AreEqual(collection[0], publicDetails); Assert.AreEqual(collection[publicAddress], publicDetails); Assert.AreEqual(collection[1], miningDetails); Assert.AreEqual(collection[miningAddress], miningDetails); Assert.AreEqual(collection[2], miscDetails); Assert.AreEqual(collection[miscAddress], miscDetails); collection.Remove(publicAddress); Assert.AreEqual(collection.Count, 2); Assert.AreEqual(collection[0], miningDetails); Assert.AreEqual(collection[miningAddress], miningDetails); Assert.AreEqual(collection[1], miscDetails); Assert.AreEqual(collection[miscAddress], miscDetails); collection.Insert(1, publicDetails); Assert.AreEqual(collection.Count, 3); Assert.AreEqual(collection[0], miningDetails); Assert.AreEqual(collection[miningAddress], miningDetails); Assert.AreEqual(collection[1], publicDetails); Assert.AreEqual(collection[publicAddress], publicDetails); Assert.AreEqual(collection[2], miscDetails); Assert.AreEqual(collection[miscAddress], miscDetails); collection.RemoveAt(2); Assert.AreEqual(collection.Count, 2); Assert.AreEqual(collection[0], miningDetails); Assert.AreEqual(collection[miningAddress], miningDetails); Assert.AreEqual(collection[1], publicDetails); Assert.AreEqual(collection[publicAddress], publicDetails); }
//Address parsing conformant to RFC2822's addr-spec. /// <summary> /// Parses a string containing addresses in the following formats : /// <list type="circle"> /// <item>"John Doe" <[email protected]>,"Mike Johns" <[email protected]></item> /// <item>"John Doe" <[email protected]>;"Mike Johns" <[email protected]></item> /// <item><[email protected]></item> /// <item>[email protected]</item> /// </list> /// </summary> /// <param name="input">A string containing addresses in the formats desribed above.</param> /// <returns>An AddressCollection object containing the parsed addresses.</returns> public static AddressCollection ParseAddresses(string input) { AddressCollection addresses = new AddressCollection(); string[] comma_separated = input.Split(','); for(int i=0;i<comma_separated.Length;i++) if(comma_separated[i].IndexOf("@")==-1 && comma_separated.Length>(i+1)) comma_separated[i+1] = comma_separated[i]+comma_separated[i+1]; for(int i=0;i<comma_separated.Length;i++) /*if(comma_separated[i].IndexOf("@")!=-1)*/ addresses.Add(Parser.ParseAddress((comma_separated[i].IndexOf("<")!=-1 && comma_separated[i].IndexOf(":")!=-1 && comma_separated[i].IndexOf(":")<comma_separated[i].IndexOf("<")) ? ((comma_separated[i].Split(':')[0].IndexOf("\"")==-1) ? comma_separated[i].Split(':')[1] : comma_separated[i]) : comma_separated[i])); return addresses; }
/// <summary> /// Gets the addresses from the details array /// </summary> /// <returns>A <see cref="AddressCollection"/></returns> private static AddressCollection ParseAddresses() { AddressCollection addressCollection = new AddressCollection(); var addressStrings = _contactDetails.Where(s => s.StartsWith("ADR")); foreach (string addressStr in addressStrings) { string addressString = addressStr.Replace("ADR;", "").Replace("ADR:", ""); addressString = addressString.Replace("TYPE=", ""); //Remove multiple typing if (addressString.Contains(",")) { int index = addressString.LastIndexOf(","); addressString = addressString.Remove(0, index + 1); } //Logic if (addressString.StartsWith("HOME:") || addressString.StartsWith("home:")) { addressString = addressString.Replace("HOME:", "").Replace("home:", ""); Address address = new Address { Location = addressString.Replace(";", " "), Type = AddressType.Home }; addressCollection.Add(address); } else if (addressString.StartsWith("WORK:") || addressString.StartsWith("work:")) { addressString = addressString.Replace("WORK:", "").Replace("work:", ""); Address address = new Address { Location = addressString.Replace(";", " "), Type = AddressType.Work }; addressCollection.Add(address); } else if (addressString.StartsWith("DOM:") || addressString.StartsWith("dom:")) { addressString = addressString.Replace("DOM:", "").Replace("dom:", ""); Address address = new Address { Location = addressString.Replace(";", " "), Type = AddressType.Domestic }; addressCollection.Add(address); } else if (addressString.StartsWith("INTL:") || addressString.StartsWith("intl:")) { addressString = addressString.Replace("INTL:", "").Replace("intl:", ""); Address address = new Address { Location = addressString.Replace(";", " "), Type = AddressType.International }; addressCollection.Add(address); } else if (addressString.StartsWith("PARCEL:") || addressString.StartsWith("parcel:")) { addressString = addressString.Replace("PARCEL:", "").Replace("parcel:", ""); Address address = new Address { Location = addressString.Replace(";", " "), Type = AddressType.Parcel }; addressCollection.Add(address); } else if (addressString.StartsWith("POSTAL:") || addressString.StartsWith("postal:")) { addressString = addressString.Replace("POSTAL:", "").Replace("postal:", ""); Address address = new Address { Location = addressString.Replace(";", " "), Type = AddressType.Postal }; addressCollection.Add(address); } else { Address address = new Address { Location = addressString.Replace(";", " "), Type = AddressType.None }; addressCollection.Add(address); } } return(addressCollection); }
/// <summary> /// Gets the addresses from the details array /// </summary> /// <returns>A <see cref="AddressCollection"/></returns> private static AddressCollection ParseAddresses() { AddressCollection addressCollection = new AddressCollection(); var addressStrings = _contactDetails.Where(s => s.StartsWith("ADR")); foreach (string addressStr in addressStrings) { string addressString = addressStr.Replace("ADR;", "").Replace("ADR:", ""); if (addressString.StartsWith("HOME:")) { addressString = addressString.Replace("HOME:", ""); Address address = new Address { Location = addressString.Replace(";", " "), Type = AddressType.Home }; addressCollection.Add(address); } else if (addressString.StartsWith("WORK:")) { addressString = addressString.Replace("WORK:", ""); Address address = new Address { Location = addressString.Replace(";", " "), Type = AddressType.Work }; addressCollection.Add(address); } else if (addressString.StartsWith("DOM:") || addressString.StartsWith("dom:")) { addressString = addressString.Replace("DOM:", "").Replace("dom:", ""); Address address = new Address { Location = addressString.Replace(";", " "), Type = AddressType.Domestic }; addressCollection.Add(address); } else if (addressString.StartsWith("INTL:") || addressString.StartsWith("intl:")) { addressString = addressString.Replace("INTL:", "").Replace("intl:", ""); Address address = new Address { Location = addressString.Replace(";", " "), Type = AddressType.International }; addressCollection.Add(address); } else if (addressString.StartsWith("PARCEL:") || addressString.StartsWith("parcel:")) { addressString = addressString.Replace("PARCEL:", "").Replace("parcel:", ""); Address address = new Address { Location = addressString.Replace(";", " "), Type = AddressType.Parcel }; addressCollection.Add(address); } else if (addressString.StartsWith("POSTAL:") || addressString.StartsWith("postal:")) { addressString = addressString.Replace("POSTAL:", "").Replace("postal:", ""); Address address = new Address { Location = addressString.Replace(";", " "), Type = AddressType.Postal }; addressCollection.Add(address); } else { Address address = new Address { Location = addressString.Replace(";", " "), Type = AddressType.None }; addressCollection.Add(address); } } return(addressCollection); }