Code:
/ WCF / WCF / 3.5.30729.1 / untmp / Orcas / SP / ndp / cdf / src / WCF / infocard / Service / managed / Microsoft / InfoCards / HttpProxyTransportBindingElement.cs / 2 / HttpProxyTransportBindingElement.cs
//------------------------------------------------------------ // Copyright (c) Microsoft Corporation. All rights reserved. //----------------------------------------------------------- namespace Microsoft.InfoCards { using System.Collections.Generic; using System.ServiceModel.Description; using System.ServiceModel; using System.Net; using System.ServiceModel.Channels; using IDT = Microsoft.InfoCards.Diagnostics.InfoCardTrace; // // This class is used to replace the TransportBindingElement to a binding element which uses the user's proxy // class HttpProxyTransportBindingElement :TransportBindingElement { HttpTransportBindingElement innerHttpTransport; IWebProxy proxy; // // Summary: // Replaces the HttpTransportBindingElement from the collection with HttpProxyTransportBindingElement // // Arguments: // bindingElements: The bindingElements collection to update // proxy: The proxy to be used for HttpTransport // turnOffClientAuthOnTransport: When set to true, the AuthenticationScheme for the transport // binding will be set to ANonymous // // Returns: // Returns the updated bindingElements collection. // public static BindingElementCollection ReplaceHttpTransportWithProxy( BindingElementCollection bindingElements, IWebProxy proxy, bool turnOffClientAuthOnTransport ) { int httpIndex = -1; for( int i = 0; i < bindingElements.Count; i++ ) { if( bindingElements[ i ] is HttpTransportBindingElement ) { httpIndex = i; break; } } if( httpIndex == -1 ) { // no HttpTransport to wrap, just return original binding return bindingElements; } IDT.Assert( httpIndex == bindingElements.Count - 1, "Transport should be last in the Binding Element list" ); HttpTransportBindingElement httpTransport = ( HttpTransportBindingElement )bindingElements[ httpIndex ]; if( turnOffClientAuthOnTransport ) { httpTransport.AuthenticationScheme = AuthenticationSchemes.Anonymous; } HttpProxyTransportBindingElement proxyTransport = new HttpProxyTransportBindingElement( proxy, httpTransport ); bindingElements[ httpIndex ] = proxyTransport; return bindingElements; } HttpProxyTransportBindingElement( IWebProxy proxy, HttpTransportBindingElement innerHttpTransport ) : base() { this.innerHttpTransport = innerHttpTransport; this.proxy = proxy; } HttpProxyTransportBindingElement( HttpProxyTransportBindingElement elementToBeCloned ) : base( elementToBeCloned ) { this.innerHttpTransport = elementToBeCloned.innerHttpTransport; this.proxy = elementToBeCloned.proxy; } public override long MaxBufferPoolSize { get { return this.innerHttpTransport.MaxBufferPoolSize; } set { this.innerHttpTransport.MaxBufferPoolSize = value; } } public override long MaxReceivedMessageSize { get { return this.innerHttpTransport.MaxReceivedMessageSize; } set { this.innerHttpTransport.MaxReceivedMessageSize = value; } } public override string Scheme { get { return this.innerHttpTransport.Scheme; } } public override IChannelFactoryBuildChannelFactory ( BindingContext context ) { this.innerHttpTransport.Proxy = this.proxy; HttpChannelFactory factory = (HttpChannelFactory)this.innerHttpTransport.BuildChannelFactory (context); return (IChannelFactory )(object)factory; } public override IChannelListener BuildChannelListener ( BindingContext context ) { return this.innerHttpTransport.BuildChannelListener ( context ); } public override bool CanBuildChannelFactory ( BindingContext context ) { return this.innerHttpTransport.CanBuildChannelFactory ( context ); } public override bool CanBuildChannelListener ( BindingContext context ) { return this.innerHttpTransport.CanBuildChannelListener ( context ); } public override BindingElement Clone() { return new HttpProxyTransportBindingElement( this ); } public override T GetProperty ( BindingContext context ) { return this.innerHttpTransport.GetProperty ( context ); } } } // 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
- FloaterParagraph.cs
- XmlDataCollection.cs
- DateTimeUtil.cs
- GridProviderWrapper.cs
- HtmlTableCell.cs
- Random.cs
- RangeContentEnumerator.cs
- EntityDataSourceContextDisposingEventArgs.cs
- ZipIOLocalFileDataDescriptor.cs
- metadatamappinghashervisitor.hashsourcebuilder.cs
- XmlArrayItemAttribute.cs
- TypeDelegator.cs
- ShaperBuffers.cs
- XmlDataSourceView.cs
- XmlWriterSettings.cs
- _ListenerRequestStream.cs
- wmiprovider.cs
- Table.cs
- MouseEventArgs.cs
- ButtonChrome.cs
- HttpRequestTraceRecord.cs
- VariantWrapper.cs
- LogLogRecordEnumerator.cs
- Globals.cs
- ListViewInsertionMark.cs
- HttpHostedTransportConfiguration.cs
- LockRecursionException.cs
- PackageProperties.cs
- MgmtConfigurationRecord.cs
- OleStrCAMarshaler.cs
- ConfigXmlWhitespace.cs
- PropertyFilter.cs
- WindowsAuthenticationEventArgs.cs
- SqlServices.cs
- DataGridToolTip.cs
- TextLineResult.cs
- DependencyObjectValidator.cs
- NameValueFileSectionHandler.cs
- SecurityKeyIdentifierClause.cs
- shaperfactory.cs
- OracleConnectionFactory.cs
- UnescapedXmlDiagnosticData.cs
- RIPEMD160Managed.cs
- AccessDataSourceWizardForm.cs
- CatalogPartCollection.cs
- X509Chain.cs
- PriorityItem.cs
- DataObjectAttribute.cs
- CodeDefaultValueExpression.cs
- Size.cs
- TextEditorTables.cs
- InstanceNameConverter.cs
- DataGridViewColumn.cs
- DataPagerFieldCommandEventArgs.cs
- GridViewRowCollection.cs
- TemplateEditingService.cs
- FactoryMaker.cs
- FileClassifier.cs
- ValidationHelpers.cs
- DesignerAdapterUtil.cs
- RSAPKCS1SignatureFormatter.cs
- LoadWorkflowCommand.cs
- Thread.cs
- RubberbandSelector.cs
- XamlFrame.cs
- Parameter.cs
- PrivacyNoticeBindingElementImporter.cs
- GridViewCancelEditEventArgs.cs
- Dynamic.cs
- XmlSchemaDatatype.cs
- ScrollData.cs
- SpellerError.cs
- DataViewSettingCollection.cs
- wgx_render.cs
- DataGridViewCellContextMenuStripNeededEventArgs.cs
- HttpConfigurationSystem.cs
- ProxyGenerationError.cs
- ElapsedEventArgs.cs
- ToolStripPanelCell.cs
- InfoCardRequestException.cs
- DataViewListener.cs
- _OverlappedAsyncResult.cs
- KeyManager.cs
- BamlTreeMap.cs
- DeflateStream.cs
- EnumerableRowCollectionExtensions.cs
- SchemaNamespaceManager.cs
- SHA256.cs
- PathFigureCollectionConverter.cs
- TraceLevelStore.cs
- Utility.cs
- UnsafeNativeMethods.cs
- PageHandlerFactory.cs
- versioninfo.cs
- DecoderReplacementFallback.cs
- JoinTreeSlot.cs
- CacheHelper.cs
- SequentialWorkflowHeaderFooter.cs
- TypeToTreeConverter.cs
- LinkLabelLinkClickedEvent.cs