📄 recipientcollection.cs
字号:
// $Id: RecipientCollection.cs,v 1.2 2006/08/07 11:06:09 ethem Exp $
namespace Erle.DnsMail
{
using System;
using System.Collections;
public sealed class RecipientCollection : ArrayList
{
public RecipientCollection() : base() { }
public RecipientCollection(int capacity) : base(capacity) { }
public RecipientCollection(bool usesMailServer)
: this()
{
ums = usesMailServer;
}
public override int Add(Object recipient)
{
if (recipient == null)
throw new ArgumentNullException("recipient");
Recipient tmpAdd;
if (recipient is Recipient)
tmpAdd = recipient as Recipient;
else if (recipient is String)
tmpAdd = new Recipient(recipient as String);
else
throw new ArgumentException(String.Format("Add a Recipient or String object. You used: {0}", recipient.GetType().FullName), "recipient");
if ((tmpAdd.Email == null) || (tmpAdd.Email == string.Empty))
throw new EmailException(String.Format("Email address cannot be null. Count: {0}", Count));
if (!ums)
{
if (Count == 0)
{
if ((domain = DnsMail.FindEmailDomain(tmpAdd.Email)) == null)
throw new EmailException(String.Format("{0} isn't a valid email address.", tmpAdd.Email));
}
else
{
if (domain != DnsMail.FindEmailDomain(tmpAdd.Email))
throw new EmailException(String.Format("{0} cannot add; All Recipients' domains must be @{1}.", tmpAdd.Email, domain));
}
return base.Add(tmpAdd);
}
else
{
if (DnsMail.EmailCheck(tmpAdd.Email))
return base.Add(tmpAdd);
else
throw new EmailException(String.Format("{0} isn't a valid email address.", tmpAdd.Email));
}
}
public override Object this[int index]
{
get { return base[index]; }
set { throw new NotSupportedException(); }
}
public override void Insert(int index, Object recipient)
{
this.Add(recipient);
}
private bool ums;
private string domain;
public string Domain
{
get { return domain; }
}
}
};
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -