public void Read(XmlNode node) { if (node == null) { throw new ArgumentNullException("node"); } XmlAttributeCollection attrs = node.Attributes; string host = attrs.GetRequired <string> ("host"); if (host.Length == 0) { throw new InvalidOperationException("The host attribute must not be empty."); } Host = host; int port = attrs.GetOptional <int> ("port", 25); if (port < 1 || port > 65535) { throw new InvalidOperationException("Port must be an integer between 1 and 65535"); } Port = port; EnableSSL = attrs.GetOptional <bool> ("enableSSL", true); user = attrs.GetOptional <string> ("user", null); password = attrs.GetOptional <string> ("password", null); }
public void Read(XmlNode node) { if (node == null) { return; } XmlAttributeCollection attrs = node.Attributes; ID = attrs.GetRequired <string> ("id"); SendAsCommitter = attrs.GetOptional("sendAsCommitter", false); UseCommitterAsSenderName = attrs.GetOptional("useCommitterAsSenderName", false); Author addr = ReadEmail(node.SelectSingleNode("//from")); if (!SendAsCommitter && addr == null) { throw new InvalidOperationException(String.Format("Required <from> element is missing from commit source with id '{0}'", ID)); } From = addr; addr = ReadEmail(node.SelectSingleNode("//replyTo")); if (addr == null) { ReplyTo = From; } else { ReplyTo = addr; } ReadEmails(node.SelectNodes("//to/email"), TORecipients); if (TORecipients.Count == 0) { throw new InvalidOperationException("List of TO addresses must have at least one element"); } ReadEmails(node.SelectNodes("//cc/email"), CCRecipients); ReadEmails(node.SelectNodes("//bcc/email"), BCCRecipients); }