private static ICredentials GetBasicCredentials(Uri uri, bool forcePrompt)
{
string proxyHost = uri.Host;
ICredentials basicCredentials = null;
using (PromptForCredential dialog = new PromptForCredential()) {
dialog.TargetName = string.Format(CultureInfo.InvariantCulture, "PackageExplorer_{0}", proxyHost);
dialog.Title = string.Format(CultureInfo.CurrentCulture, "Connect to {0}", proxyHost);
dialog.Message = dialog.Title;
dialog.GenericCredentials = true;
dialog.AlwaysShowUI = forcePrompt;
if (dialog.ShowDialog()) {
basicCredentials = new NetworkCredential(dialog.UserName, dialog.Password);
}
}
return basicCredentials;
}