Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / cdf / src / NetFx40 / System.ServiceModel.Discovery / System / ServiceModel / Discovery / DiscoveryClientChannelFactory.cs / 1305376 / DiscoveryClientChannelFactory.cs
//---------------------------------------------------------------- // Copyright (c) Microsoft Corporation. All rights reserved. //--------------------------------------------------------------- namespace System.ServiceModel.Discovery { using System; using System.Runtime; using System.ServiceModel; using System.ServiceModel.Channels; class DiscoveryClientChannelFactory: ChannelFactoryBase { DiscoveryEndpointProvider discoveryEndpointProvider; FindCriteria findCriteria; IChannelFactory innerChannelFactory; public DiscoveryClientChannelFactory(IChannelFactory innerChannelFactory, FindCriteria findCriteria, DiscoveryEndpointProvider discoveryEndpointProvider) { Fx.Assert(findCriteria != null, "The findCriteria must be non null."); Fx.Assert(discoveryEndpointProvider != null, "The discoveryEndpointProvider must be non null."); Fx.Assert(innerChannelFactory != null, "The innerChannelFactory must be non null."); this.findCriteria = findCriteria; this.discoveryEndpointProvider = discoveryEndpointProvider; this.innerChannelFactory = innerChannelFactory; } protected override TChannel OnCreateChannel(EndpointAddress address, Uri via) { if (!address.Equals(DiscoveryClientBindingElement.DiscoveryEndpointAddress)) { throw FxTrace.Exception.Argument( "address", Discovery.SR.DiscoveryEndpointAddressIncorrect("address", address.Uri, DiscoveryClientBindingElement.DiscoveryEndpointAddress.Uri)); } if (!via.Equals(DiscoveryClientBindingElement.DiscoveryEndpointAddress.Uri)) { throw FxTrace.Exception.Argument( "via", Discovery.SR.DiscoveryEndpointAddressIncorrect("via", via, DiscoveryClientBindingElement.DiscoveryEndpointAddress.Uri)); } if (typeof(TChannel) == typeof(IOutputChannel)) { return (TChannel)(object)new DiscoveryClientOutputChannel ( this, (IChannelFactory )this.innerChannelFactory, this.findCriteria, this.discoveryEndpointProvider); } else if (typeof(TChannel) == typeof(IRequestChannel)) { return (TChannel)(object)new DiscoveryClientRequestChannel ( this, (IChannelFactory )this.innerChannelFactory, this.findCriteria, this.discoveryEndpointProvider); } else if (typeof(TChannel) == typeof(IDuplexChannel)) { return (TChannel)(object)new DiscoveryClientDuplexChannel ( this, (IChannelFactory )this.innerChannelFactory, this.findCriteria, this.discoveryEndpointProvider); } else if (typeof(TChannel) == typeof(IOutputSessionChannel)) { return (TChannel)(object)new DiscoveryClientOutputSessionChannel( this, (IChannelFactory )this.innerChannelFactory, this.findCriteria, this.discoveryEndpointProvider); } else if (typeof(TChannel) == typeof(IRequestSessionChannel)) { return (TChannel)(object)new DiscoveryClientRequestSessionChannel( this, (IChannelFactory )this.innerChannelFactory, this.findCriteria, this.discoveryEndpointProvider); } else if (typeof(TChannel) == typeof(IDuplexSessionChannel)) { return (TChannel)(object)new DiscoveryClientDuplexSessionChannel( this, (IChannelFactory )this.innerChannelFactory, this.findCriteria, this.discoveryEndpointProvider); } throw FxTrace.Exception.Argument("TChannel", ServiceModel.SR.GetString(ServiceModel.SR.ChannelTypeNotSupported, typeof(TChannel))); } public override T GetProperty () { if (typeof(T) == typeof(IChannelFactory )) { return (T)(object)this; } T baseProperty = base.GetProperty (); if (baseProperty != null) { return baseProperty; } return this.innerChannelFactory.GetProperty (); } protected override IAsyncResult OnBeginOpen(TimeSpan timeout, AsyncCallback callback, object state) { return this.innerChannelFactory.BeginOpen(timeout, callback, state); } protected override void OnEndOpen(IAsyncResult result) { this.innerChannelFactory.EndOpen(result); } protected override void OnOpen(TimeSpan timeout) { this.innerChannelFactory.Open(timeout); } protected override IAsyncResult OnBeginClose(TimeSpan timeout, AsyncCallback callback, object state) { // Must close higher channels before closing lower channels. return new ChainedAsyncResult( timeout, callback, state, base.OnBeginClose, base.OnEndClose, this.innerChannelFactory.BeginClose, this.innerChannelFactory.EndClose); } protected override void OnEndClose(IAsyncResult result) { ChainedAsyncResult.End(result); } protected override void OnClose(TimeSpan timeout) { // Must close higher channels before closing lower channels. TimeoutHelper timeoutHelper = new TimeoutHelper(timeout); base.OnClose(timeoutHelper.RemainingTime()); this.innerChannelFactory.Close(timeoutHelper.RemainingTime()); } protected override void OnAbort() { // Must abort higher channels before aborting lower channels. base.OnAbort(); this.innerChannelFactory.Abort(); } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- ProcessManager.cs
- CopyCodeAction.cs
- Compress.cs
- CompositeDataBoundControl.cs
- EntityDataSourceStatementEditorForm.cs
- HelloOperationAsyncResult.cs
- EncryptedKey.cs
- BamlTreeNode.cs
- FileChangesMonitor.cs
- XmlObjectSerializer.cs
- TimeoutValidationAttribute.cs
- SqlConnectionPoolGroupProviderInfo.cs
- ConnectionProviderAttribute.cs
- ComboBox.cs
- ReliabilityContractAttribute.cs
- HMACMD5.cs
- ZipIOCentralDirectoryFileHeader.cs
- ResetableIterator.cs
- Substitution.cs
- CustomAttributeBuilder.cs
- ControlCachePolicy.cs
- CapabilitiesState.cs
- ProxyAttribute.cs
- Literal.cs
- QueryBranchOp.cs
- XPathException.cs
- FreezableCollection.cs
- GroupBoxAutomationPeer.cs
- PhonemeConverter.cs
- SingleQueryOperator.cs
- TreeNodeBindingCollection.cs
- TypeReference.cs
- Vector3DConverter.cs
- Utils.cs
- ExpressionEditor.cs
- TemplatePartAttribute.cs
- PipelineModuleStepContainer.cs
- XmlSchemaFacet.cs
- assemblycache.cs
- DispatchChannelSink.cs
- Section.cs
- SqlServices.cs
- ListViewGroupItemCollection.cs
- VideoDrawing.cs
- CqlQuery.cs
- DocumentPageView.cs
- Error.cs
- CheckBoxPopupAdapter.cs
- DataGridViewRowDividerDoubleClickEventArgs.cs
- RuleSettings.cs
- EntityTransaction.cs
- XmlEntity.cs
- ServiceModelExtensionCollectionElement.cs
- OutputCacheModule.cs
- DesignerToolboxInfo.cs
- x509utils.cs
- ListBoxItemWrapperAutomationPeer.cs
- SynchronousReceiveBehavior.cs
- IntPtr.cs
- IPAddressCollection.cs
- BitConverter.cs
- CodeGen.cs
- DataGridViewHeaderCell.cs
- StructuredTypeEmitter.cs
- HttpListenerPrefixCollection.cs
- PropertyChangedEventArgs.cs
- PointAnimationClockResource.cs
- RecommendedAsConfigurableAttribute.cs
- TranslateTransform3D.cs
- DataGridColumnHeaderItemAutomationPeer.cs
- KeyConstraint.cs
- TableTextElementCollectionInternal.cs
- TaskbarItemInfo.cs
- RIPEMD160.cs
- SystemWebExtensionsSectionGroup.cs
- SyndicationPerson.cs
- TextTrailingCharacterEllipsis.cs
- XmlUtilWriter.cs
- BitmapSizeOptions.cs
- ManipulationInertiaStartingEventArgs.cs
- PerformanceCounterPermissionAttribute.cs
- CodeIdentifier.cs
- CompatibleComparer.cs
- XmlMemberMapping.cs
- AttributeCollection.cs
- ContentWrapperAttribute.cs
- FileDataSourceCache.cs
- UIElementCollection.cs
- ChtmlLinkAdapter.cs
- ServiceDebugElement.cs
- SqlConnectionHelper.cs
- SelectionRange.cs
- XmlArrayAttribute.cs
- XmlMessageFormatter.cs
- NotCondition.cs
- PipelineModuleStepContainer.cs
- LayoutSettings.cs
- tooltip.cs
- PrinterResolution.cs
- TripleDESCryptoServiceProvider.cs