using System; using System.Data; using System.Configuration; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Web.UI.HtmlControls; namespace WmHmailserverExporterWeb { public class MailAccount : IComparable{ protected int id; protected string domainName; protected string accountName; protected string password; protected static MailAccountSortBy sortBy; public int Id { get { return id; } set { id = value; } } public string DomainName { get { return domainName; } set { domainName = value; } } public string AccountName { get { return accountName; } set { accountName = value; } } public string Password { get { return password; } set { password = value; } } public static MailAccountSortBy SortBy { get { return sortBy; } set { sortBy = value; } } public int CompareTo(object obj) { if (!(obj is MailAccount)) { throw new InvalidCastException("This object is not of type MailAccount"); } MailAccount other = (MailAccount)obj; switch (sortBy) { case MailAccountSortBy.ID: return this.Id.CompareTo(other.Id); case MailAccountSortBy.ACCOUNTNAME: return this.AccountName.CompareTo(other.AccountName); case MailAccountSortBy.DOMAINNAME: return this.DomainName.CompareTo(other.DomainName); default: goto case MailAccountSortBy.ID; } } } public enum MailAccountSortBy { ID,DOMAINNAME,ACCOUNTNAME } }