protected void Parse(string proxyString)
{
if (string.IsNullOrEmpty(proxyString))
return;
try
{
var uri = new Uri(proxyString);
Hostname = uri.Host;
Port = uri.Port;
if (!string.IsNullOrEmpty(uri.UserInfo))
{
Username = uri.UserInfo;
if (Username.Contains(":"))
{
var parts = Username.Split(':');
Username = parts[0];
Password = parts[1];
}
}
}
catch (UriFormatException)
{
// We simply ignore invalid URIs (which might be as simple as missing http://)
return;
}
}