private void ProcessProxyNode(XmlNode proxy, XmlNode configNode)
{
if( proxy.ChildNodes.Count > 0 )
throw new System.Configuration.ConfigurationException("proxy element does not support child elements");
_proxyDefined = true;
foreach(XmlAttribute attribute in proxy.Attributes)
{
switch(attribute.Name)
{
case "ipaddress":
_proxyAddress = attribute.Value;
break;
case "port":
try
{
_proxyPort = int.Parse(attribute.Value);
}
catch(FormatException ex)
{
throw new System.Configuration.ConfigurationException("proxy port should be integer value", ex, configNode);
}
break;
case "username":
_proxyUsername = attribute.Value;
break;
case "password":
_proxyPassword = attribute.Value;
break;
case "domain":
_proxyDomain = attribute.Value;
break;
default:
throw new System.Configuration.ConfigurationException(String.Format("Unknown attribute '{0}' in flickrNet/proxy node", attribute.Name), configNode);
}
}
if( _proxyAddress == null )
throw new System.Configuration.ConfigurationException("proxy ipaddress is mandatory if you specify the proxy element");
if( _proxyPort == 0 )
throw new System.Configuration.ConfigurationException("proxy port is mandatory if you specify the proxy element");
if( _proxyUsername != null && _proxyPassword == null )
throw new System.Configuration.ConfigurationException("proxy password must be specified if proxy username is specified");
if( _proxyUsername == null && _proxyPassword != null )
throw new System.Configuration.ConfigurationException("proxy username must be specified if proxy password is specified");
if( _proxyDomain != null && _proxyUsername == null )
throw new System.Configuration.ConfigurationException("proxy username/password must be specified if proxy domain is specified");
}