public static List <VCard> LoadVCards(string path) { var ans = new List <VCard>(); if (!Directory.Exists(path)) { Directory.CreateDirectory(path); throw new Exception("Files not found."); } foreach (var contact in Directory.GetFiles(path)) { ans.Add(VCard.ParseText(File.ReadAllText(contact))); } return(ans); }
static VCard GetNames(string vCardLine) { var v = new VCard(); var regex = new Regex(RegxN, RegxOptions); var m = regex.Match(vCardLine); if (!m.Success) { return(v); } v.Surname = m.Groups["strSurname"].Value; v.GivenName = m.Groups["strGivenName"].Value; v.MiddleName = m.Groups["strMidName"].Value; v.Prefix = m.Groups["strPrefix"].Value; v.Suffix = m.Groups["strSuffix"].Value; return(v); }
public VCardBuilder(VCard x) { _v = x; }
public static string Print(VCard v) { if (v == null) { return("No such contact"); } var r = new StringBuilder(); r.AppendLine("Name: " + v.GivenName); r.AppendLine("Surname: " + v.Surname); if (!string.IsNullOrEmpty(v.MiddleName)) { r.AppendLine("Middle name: " + v.MiddleName); } if (!string.IsNullOrEmpty(v.Prefix)) { r.AppendLine("Prefix: " + v.Prefix); } if (!string.IsNullOrEmpty(v.Suffix)) { r.AppendLine("Suffix: " + v.Suffix); } if (!string.IsNullOrEmpty(v.Nickname)) { r.AppendLine("Nickname: " + v.Nickname); } if (v.Birthday > DateTime.MinValue) { r.AppendLine("Birthday: " + v.Birthday.ToShortDateString()); } var email = "Email: "; foreach (var t in v.Emails) { email += t.Address + ", "; } if (email != "Email: ") { r.AppendLine(email.Substring(0, email.Length - 2)); } var phone = "Telephone: "; foreach (var t in v.Phones) { phone += t.Number + ", "; } if (phone != "Telephone: ") { r.AppendLine(phone.Substring(0, phone.Length - 2)); } var url = "URL: "; foreach (var t in v.Urls) { url += t.Address + ", "; } if (url != "URL: ") { r.AppendLine(url.Substring(0, url.Length - 2)); } if (!String.IsNullOrEmpty(v.Note)) { r.AppendLine("Note:" + v.Note); } return(r.ToString()); }
public ContactConsoleRead() { vCard = new VCard(); Console.Clear(); Console.WriteLine("Please, write down the information.\n* - necessary fields"); }