コード例 #1
0
        public static EmailContact Parse(string literals)
        {
            EmailContact contact;
            var          emailMatch = Regex.Match(literals, "<.+>");

            if (emailMatch.Success)
            {
                var email   = emailMatch.Value.TrimAny(1);
                var cropped = literals.Replace(emailMatch.Value, string.Empty);
                var name    = cropped.Trim();
                name    = name.TrimQuotes();
                contact = new EmailContact(name, email);
            }
            else
            {
                contact = new EmailContact(literals.TrimQuotes());
            }

            return(contact);
        }
コード例 #2
0
ファイル: EmailContact.cs プロジェクト: pravse/CommSample
        public static EmailContact Parse(string literals)
        {
            EmailContact contact;
            var emailMatch = Regex.Match(literals, "<.+>");
            if (emailMatch.Success) {
                var email = emailMatch.Value.TrimAny(1);
                var cropped = literals.Replace(emailMatch.Value, string.Empty);
                var name = cropped.Trim();
                name = name.TrimQuotes();
                contact = new EmailContact(name, email);
            } else {
                contact = new EmailContact(literals.TrimQuotes());
            }

            return contact;
        }