private static void ParseAddXmlElement(SecurityElement et, ArrayList listToAdd, string accessStr) {
foreach(SecurityElement uriElem in et.Children) {
if (uriElem.Tag.Equals("ENDPOINT")) {
Hashtable attributes = uriElem.Attributes;
string tmpStr;
try {
tmpStr = attributes["host"] as string;
}
catch{
tmpStr = null;
}
if (tmpStr == null) {
throw new ArgumentNullException(accessStr + "host");
}
string host = tmpStr;
try {
tmpStr = attributes["transport"] as string;
}
catch{
tmpStr = null;
}
if (tmpStr == null) {
throw new ArgumentNullException(accessStr + "transport");
}
TransportType transport;
try {
transport = (TransportType) Enum.Parse(typeof(TransportType), tmpStr, true);
}
catch (Exception exception) {
if (exception is ThreadAbortException || exception is StackOverflowException || exception is OutOfMemoryException) {
throw;
}
throw new ArgumentException(accessStr + "transport", exception);
}
catch {
throw new ArgumentException(accessStr + "transport", new Exception(SR.GetString(SR.net_nonClsCompliantException)));
}
try {
tmpStr = attributes["port"] as string;
}
catch{
tmpStr = null;
}
if (tmpStr == null) {
throw new ArgumentNullException(accessStr + "port");
}
if (string.Compare(tmpStr, "All", StringComparison.OrdinalIgnoreCase ) == 0) {
tmpStr = "-1";
}
int port;
try {
port = Int32.Parse(tmpStr, NumberFormatInfo.InvariantInfo);
}
catch (Exception exception) {
if (exception is ThreadAbortException || exception is StackOverflowException || exception is OutOfMemoryException) {
throw;
}
throw new ArgumentException(SR.GetString(SR.net_perm_invalid_val, accessStr + "port", tmpStr), exception);
}
catch {
throw new ArgumentException(SR.GetString(SR.net_perm_invalid_val, accessStr + "port", tmpStr), new Exception(SR.GetString(SR.net_nonClsCompliantException)));
}
if (!ValidationHelper.ValidateTcpPort(port) && port != SocketPermission.AllPorts) {
throw new ArgumentOutOfRangeException(SR.GetString(SR.net_perm_invalid_val, accessStr + "port", tmpStr));
}
listToAdd.Add(new EndpointPermission(host, port , transport));
}
else {
// improper tag found, just ignore
}
}
}