Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / Net / System / Net / HybridWebProxyFinder.cs / 1305376 / HybridWebProxyFinder.cs
using System; using System.Collections.Generic; using System.Diagnostics; namespace System.Net { // This class behaves the same as WinHttpWebProxyFinder. The only difference is that in cases where // the script location has a scheme != HTTP, it falls back to NetWebProxyFinder which supports // also other schemes like FILE and FTP. // The mid-term goal for WinHttp is to support at least FILE scheme since it was already requested // by customers. The long term goal for System.Net is to use WinHttp only and remove this class // as well as NetWebProxyFinder. internal sealed class HybridWebProxyFinder : IWebProxyFinder { private NetWebProxyFinder netFinder; private WinHttpWebProxyFinder winHttpFinder; private BaseWebProxyFinder currentFinder; private AutoWebProxyScriptEngine engine; public HybridWebProxyFinder(AutoWebProxyScriptEngine engine) { this.engine = engine; this.winHttpFinder = new WinHttpWebProxyFinder(engine); this.currentFinder = winHttpFinder; } public bool IsValid { get { return currentFinder.IsValid; } } public bool GetProxies(Uri destination, out IListproxyList) { if (currentFinder.GetProxies(destination, out proxyList)) { return true; } if (currentFinder.IsUnrecognizedScheme && (currentFinder == winHttpFinder)) { // If WinHttpWebProxyFinder failed because the script location has a != HTTP scheme, // fall back to NetWebProxyFinder which supports also other schemes. if (netFinder == null) { netFinder = new NetWebProxyFinder(engine); } currentFinder = netFinder; return currentFinder.GetProxies(destination, out proxyList); } // Something else went wrong. Falling back to NetWebProxyFinder wouldn't help. return false; } public void Abort() { // Abort only the current finder. There is no need to abort the other one (which is either // uninitialized, i.e. not used yet, or we have an unrecognized-scheme state, which should // not be changed). currentFinder.Abort(); } public void Reset() { winHttpFinder.Reset(); if (netFinder != null) { netFinder.Reset(); } // Some settings changed, so let's reset the current finder to WinHttpWebProxyFinder, since // now it may work (if it didn't already before). currentFinder = winHttpFinder; } public void Dispose() { Dispose(true); } private void Dispose(bool disposing) { if (disposing) { winHttpFinder.Dispose(); if (netFinder != null) { netFinder.Dispose(); } } } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved. using System; using System.Collections.Generic; using System.Diagnostics; namespace System.Net { // This class behaves the same as WinHttpWebProxyFinder. The only difference is that in cases where // the script location has a scheme != HTTP, it falls back to NetWebProxyFinder which supports // also other schemes like FILE and FTP. // The mid-term goal for WinHttp is to support at least FILE scheme since it was already requested // by customers. The long term goal for System.Net is to use WinHttp only and remove this class // as well as NetWebProxyFinder. internal sealed class HybridWebProxyFinder : IWebProxyFinder { private NetWebProxyFinder netFinder; private WinHttpWebProxyFinder winHttpFinder; private BaseWebProxyFinder currentFinder; private AutoWebProxyScriptEngine engine; public HybridWebProxyFinder(AutoWebProxyScriptEngine engine) { this.engine = engine; this.winHttpFinder = new WinHttpWebProxyFinder(engine); this.currentFinder = winHttpFinder; } public bool IsValid { get { return currentFinder.IsValid; } } public bool GetProxies(Uri destination, out IList proxyList) { if (currentFinder.GetProxies(destination, out proxyList)) { return true; } if (currentFinder.IsUnrecognizedScheme && (currentFinder == winHttpFinder)) { // If WinHttpWebProxyFinder failed because the script location has a != HTTP scheme, // fall back to NetWebProxyFinder which supports also other schemes. if (netFinder == null) { netFinder = new NetWebProxyFinder(engine); } currentFinder = netFinder; return currentFinder.GetProxies(destination, out proxyList); } // Something else went wrong. Falling back to NetWebProxyFinder wouldn't help. return false; } public void Abort() { // Abort only the current finder. There is no need to abort the other one (which is either // uninitialized, i.e. not used yet, or we have an unrecognized-scheme state, which should // not be changed). currentFinder.Abort(); } public void Reset() { winHttpFinder.Reset(); if (netFinder != null) { netFinder.Reset(); } // Some settings changed, so let's reset the current finder to WinHttpWebProxyFinder, since // now it may work (if it didn't already before). currentFinder = winHttpFinder; } public void Dispose() { Dispose(true); } private void Dispose(bool disposing) { if (disposing) { winHttpFinder.Dispose(); if (netFinder != null) { netFinder.Dispose(); } } } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- HeaderElement.cs
- SBCSCodePageEncoding.cs
- TaiwanLunisolarCalendar.cs
- CryptoConfig.cs
- IndexOutOfRangeException.cs
- Renderer.cs
- MarkupObject.cs
- HtmlForm.cs
- TemplateNameScope.cs
- EDesignUtil.cs
- TraceRecord.cs
- StringKeyFrameCollection.cs
- AuthenticatedStream.cs
- SqlResolver.cs
- RemotingSurrogateSelector.cs
- ToolStripProgressBar.cs
- Decorator.cs
- QilExpression.cs
- RestHandler.cs
- XmlNotation.cs
- ToolStripOverflowButton.cs
- RegexReplacement.cs
- DocumentReferenceCollection.cs
- DataControlImageButton.cs
- UniqueID.cs
- APCustomTypeDescriptor.cs
- WebRequestModuleElement.cs
- JoinSymbol.cs
- ReceiveSecurityHeaderElementManager.cs
- DataGridRelationshipRow.cs
- FileBasedResourceGroveler.cs
- SqlTriggerAttribute.cs
- Expressions.cs
- ManagementEventWatcher.cs
- ExceptionHandlers.cs
- FixedTextPointer.cs
- IndicCharClassifier.cs
- Int16KeyFrameCollection.cs
- BackgroundWorker.cs
- SqlAliasesReferenced.cs
- SqlUtils.cs
- CodeVariableDeclarationStatement.cs
- BinaryMessageFormatter.cs
- PrintPreviewGraphics.cs
- DateTimeValueSerializer.cs
- Application.cs
- ReadContentAsBinaryHelper.cs
- TreeNode.cs
- LocatorPart.cs
- DesigntimeLicenseContext.cs
- WindowsListViewItemCheckBox.cs
- NativeMethods.cs
- CompilerTypeWithParams.cs
- BindingMemberInfo.cs
- XmlNamespaceDeclarationsAttribute.cs
- NamespaceQuery.cs
- DbConnectionPoolOptions.cs
- RIPEMD160.cs
- BasePattern.cs
- SmtpDigestAuthenticationModule.cs
- MimeBasePart.cs
- CheckBoxBaseAdapter.cs
- XmlHierarchicalDataSourceView.cs
- TypeValidationEventArgs.cs
- QueryCacheEntry.cs
- WmpBitmapEncoder.cs
- ImageFormat.cs
- ListViewGroup.cs
- DirectoryNotFoundException.cs
- ScriptResourceDefinition.cs
- TextWriterTraceListener.cs
- GeneralTransform3DTo2DTo3D.cs
- FactoryMaker.cs
- SchemaNames.cs
- LinkTarget.cs
- ComponentSerializationService.cs
- _IPv4Address.cs
- Base64Encoder.cs
- XmlCompatibilityReader.cs
- ExpandCollapseProviderWrapper.cs
- FlowDocumentPage.cs
- HostingPreferredMapPath.cs
- PresentationSource.cs
- TraceListener.cs
- TargetParameterCountException.cs
- UInt64.cs
- DbDataSourceEnumerator.cs
- QilSortKey.cs
- SiteMapPath.cs
- PageScaling.cs
- DataServiceStreamResponse.cs
- EpmAttributeNameBuilder.cs
- ThreadNeutralSemaphore.cs
- SmtpTransport.cs
- XamlReader.cs
- HtmlLink.cs
- BinaryReader.cs
- UnsafeNativeMethodsPenimc.cs
- ProcessModuleCollection.cs
- ProtocolViolationException.cs