forked from smadep/MimeTools.NET
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSharpMimeAddressCollection.cs
54 lines (45 loc) · 1.47 KB
/
SharpMimeAddressCollection.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
using System;
using System.Collections.Generic;
namespace anmar.SharpMimeTools
{
public class SharpMimeAddressCollection : List<SharpMimeAddress>
{
public SharpMimeAddressCollection(String text)
{
String[] tokens = ABNF.address_regex.Split(text);
foreach (String token in tokens)
{
if (ABNF.address_regex.IsMatch(token))
Add(new SharpMimeAddress(token));
}
}
public SharpMimeAddressCollection()
{
}
public SharpMimeAddressCollection(int capacity)
: base(capacity)
{
}
public SharpMimeAddressCollection(IEnumerable<SharpMimeAddress> collection)
: base(collection)
{
}
public static SharpMimeAddressCollection Parse(String text)
{
if (text == null)
throw new ArgumentNullException();
return new SharpMimeAddressCollection(text);
}
public override string ToString()
{
System.Text.StringBuilder text = new System.Text.StringBuilder();
foreach (SharpMimeAddress token in this)
{
text.Append(token.ToString());
if (token.Length > 0)
text.Append("; ");
}
return text.ToString();
}
}
}