/// <summary> /// Checks if the specified proxy settings contains valid manual settings. /// </summary> /// <param name="settings">The reference to settings object to be checked.</param> /// <returns>true if and only if the specified settings object contains valid /// settings.</returns> private bool _HasValidManualSettings(ProxySettings settings) { if (!settings.UseManualConfiguration) { return false; } if (!_validator.Validate(settings.HttpSettings.Host).IsValid) { return false; } if (settings.UseSameSettings) { return true; } if (!_validator.Validate(settings.HttpsSettings.Host).IsValid) { return false; } return true; }
/// <summary> /// Creates a new <see cref="IWebProxy"/> object from the specified settings without /// applying authentication credentials. /// </summary> /// <param name="settings">The reference to the proxy settings to create proxy object /// from.</param> /// <returns>A new <see cref="IWebProxy"/> object based on the specified settings.</returns> private IWebProxy _Create(ProxySettings settings) { Debug.Assert(settings != null); if (!_HasValidManualSettings(settings)) { return WebRequest.GetSystemWebProxy(); } var httpProxy = _Create(settings.HttpSettings); if (settings.UseSameSettings) { return httpProxy; } var httpsProxy = _Create(settings.HttpsSettings); var proxy = new AggregateWebProxy(); proxy.AddProxy("http", httpProxy); proxy.AddProxy("https", httpsProxy); return proxy; }