public static void EnsureWebClient(WebSource source, IEnumerable<string> headers)
{
if(source != null && source.Client != null)
{
return;
}
if(source != null)
{
source.Client = new WebClient();
if(source.AuthenticationType == AuthenticationType.User)
{
source.Client.Credentials = new NetworkCredential(source.UserName, source.Password);
}
source.Client.Headers.Add("user-agent", GlobalConstants.UserAgentString );
if(headers != null)
{
foreach(var header in headers)
{
source.Client.Headers.Add(header.Trim());
}
}
}
}