blob: 20ee71f7fb98a8c2d1e6edfaf2b91014b6e6502c (
plain)
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
|
//
// System.Web.Mail.MailAddressCollection.cs
//
// Author(s):
// Per Arneng <pt99par@student.bth.se>
//
//
using System;
using System.Text;
using System.Collections;
namespace System.Web.Mail {
// represents a collection of MailAddress objects
internal class MailAddressCollection : IEnumerable {
protected ArrayList data = new ArrayList();
public MailAddress this[ int index ] {
get { return this.Get( index ); }
}
public int Count { get { return data.Count; } }
public void Add( MailAddress addr ) { data.Add( addr ); }
public MailAddress Get( int index ) { return (MailAddress)data[ index ]; }
public IEnumerator GetEnumerator() {
return data.GetEnumerator();
}
public override string ToString() {
StringBuilder builder = new StringBuilder();
for( int i = 0; i <data.Count ; i++ ) {
MailAddress addr = this.Get( i );
builder.Append( addr );
if( i != ( data.Count - 1 ) ) builder.Append( ",\r\n " );
}
return builder.ToString();
}
public static MailAddressCollection Parse( string str ) {
if( str == null ) throw new ArgumentNullException("Null is not allowed as an address string");
MailAddressCollection list = new MailAddressCollection();
string[] parts = str.Split( new char[] { ',' , ';' } );
foreach( string part in parts ) {
MailAddress add = MailAddress.Parse (part);
if (add == null)
continue;
list.Add (add);
}
return list;
}
}
}
|