扫一扫
分享文章到微信
扫一扫
关注官方公众号
至顶头条
<BlogConfigurationSettings> <MailSettings> <MailSetting Name="ApproveEmail" SmtpServer="smtp.126.com" EmailFrom="" UserName="" PassWord=""></MailSetting> <MailSetting Name="ContactEmail" SmtpServer="smtp.163.com" EmailFrom="" UserName="" PassWord=""></MailSetting> </MailSettings> </BlogConfigurationSettings> |
MailSetting [Serializable] public class MailSetting { private string _name; [XmlAttribute("Name")] public string Name { get { return _name; } set { _name = value; } } private string _smtpServer; [XmlAttribute("SmtpServer")] public string SmtpServer { get { return _smtpServer; } set { _smtpServer = value; } } private string _mailFrom; [XmlAttribute("MailFrom")] public string MailFrom { get { return _mailFrom; } set { _mailFrom = value; } } private string _username; [XmlAttribute("UserName")] public string UserName { get { return _username; } set { _username = value; } } private string _password; [XmlAttribute("Password")] public string Password { get { return _password; } set { _password = value; } } public string Key { get { return this.Name; } } } |
private MailSetting [] __mailSettings; [XmlArray("MailSettings")] public MailSetting [] MailSettings { get { return this._mailSettings; } set { this._mailSettings = value; } } |
private MailSettingColletion _mailSettings; [XmlArray("MailSettings")] public MailSettingColletion MailSettings { get { return this._mailSettings; } set { this._mailSettings = value; } } |
private List<MailSetting> _mailSettings; [XmlArray("MailSettings")] public List<MailSetting> MailSettings { get { return _mailSettings; } set { _mailSettings = value;} } |
BlogConfigurationSettings.MailSettings.Find(delegate(MailSetting mailSetting) { return mailSetting.Key == "ApproveEmail"; }) |
public delegate bool Predicate<T>(T obj) |
BlogConfigurationSettings.MailSettings.Find(IsMe); public bool IsMe(MailSetting mailSetting) { return mailSetting.Key == "ApproveEmail"; } |
public bool IsMe(MailSetting mailSetting,string key) { return mailSetting.Key == key; } |
public class MailSettingPredicate { private string key; public string Key { get { return key; } set { key = value; } } public bool IsMe(MailSetting mailSetting) { return mailSetting.Key == this.key; } } |
MailSettingPredicate predicate= new MailSettingPredicate(); predicate.Key = "ApproveEmail"; Config.Settings.MailSettings.Find(predicate.IsMe); predicate.Key = "ContactEmail"; Config.Settings.MailSettings.Find(predicate.IsMe); |
如果您非常迫切的想了解IT领域最新产品与技术信息,那么订阅至顶网技术邮件将是您的最佳途径之一。
现场直击|2021世界人工智能大会
直击5G创新地带,就在2021MWC上海
5G已至 转型当时——服务提供商如何把握转型的绝佳时机
寻找自己的Flag
华为开发者大会2020(Cloud)- 科技行者