Code:
/ WCF / WCF / 3.5.30729.1 / untmp / Orcas / SP / ndp / cdf / src / WCF / ServiceModel / System / ServiceModel / Channels / DuplexChannel.cs / 1 / DuplexChannel.cs
//------------------------------------------------------------ // Copyright (c) Microsoft Corporation. All rights reserved. //----------------------------------------------------------- namespace System.ServiceModel.Channels { using System.Collections.Generic; using System.ServiceModel; abstract class DuplexChannel : InputQueueChannel, IDuplexChannel { EndpointAddress localAddress; protected DuplexChannel(ChannelManagerBase channelManager, EndpointAddress localAddress) : base(channelManager) { this.localAddress = localAddress; } public virtual EndpointAddress LocalAddress { get { return localAddress; } } public abstract EndpointAddress RemoteAddress { get; } public abstract Uri Via { get; } public IAsyncResult BeginSend(Message message, AsyncCallback callback, object state) { return this.BeginSend(message, this.DefaultSendTimeout, callback, state); } public IAsyncResult BeginSend(Message message, TimeSpan timeout, AsyncCallback callback, object state) { if (message == null) throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("message"); if (timeout < TimeSpan.Zero) throw DiagnosticUtility.ExceptionUtility.ThrowHelperError( new ArgumentOutOfRangeException("timeout", timeout, SR.GetString(SR.SFxTimeoutOutOfRange0))); ThrowIfDisposedOrNotOpen(); AddHeadersTo(message); return OnBeginSend(message, timeout, callback, state); } public void EndSend(IAsyncResult result) { OnEndSend(result); } public override T GetProperty () { if (typeof(T) == typeof(IDuplexChannel)) { return (T)(object)this; } T baseProperty = base.GetProperty (); if (baseProperty != null) { return baseProperty; } return default(T); } protected abstract void OnSend(Message message, TimeSpan timeout); protected virtual IAsyncResult OnBeginSend(Message message, TimeSpan timeout, AsyncCallback callback, object state) { OnSend(message, timeout); return new CompletedAsyncResult(callback, state); } protected virtual void OnEndSend(IAsyncResult result) { CompletedAsyncResult.End(result); } public void Send(Message message) { this.Send(message, this.DefaultSendTimeout); } public void Send(Message message, TimeSpan timeout) { if (message == null) throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("message"); if (timeout < TimeSpan.Zero) throw DiagnosticUtility.ExceptionUtility.ThrowHelperError( new ArgumentOutOfRangeException("timeout", timeout, SR.GetString(SR.SFxTimeoutOutOfRange0))); ThrowIfDisposedOrNotOpen(); AddHeadersTo(message); OnSend(message, timeout); } protected virtual void AddHeadersTo(Message message) { } public Message Receive() { return this.Receive(this.DefaultReceiveTimeout); } public Message Receive(TimeSpan timeout) { if (timeout < TimeSpan.Zero) throw DiagnosticUtility.ExceptionUtility.ThrowHelperError( new ArgumentOutOfRangeException("timeout", timeout, SR.GetString(SR.SFxTimeoutOutOfRange0))); this.ThrowPending(); return InputChannel.HelpReceive(this, timeout); } public IAsyncResult BeginReceive(AsyncCallback callback, object state) { return this.BeginReceive(this.DefaultReceiveTimeout, callback, state); } public IAsyncResult BeginReceive(TimeSpan timeout, AsyncCallback callback, object state) { if (timeout < TimeSpan.Zero) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError( new ArgumentOutOfRangeException("timeout", timeout, SR.GetString(SR.SFxTimeoutOutOfRange0))); } this.ThrowPending(); return InputChannel.HelpBeginReceive(this, timeout, callback, state); } public Message EndReceive(IAsyncResult result) { return InputChannel.HelpEndReceive(result); } public bool TryReceive(TimeSpan timeout, out Message message) { if (timeout < TimeSpan.Zero) throw DiagnosticUtility.ExceptionUtility.ThrowHelperError( new ArgumentOutOfRangeException("timeout", timeout, SR.GetString(SR.SFxTimeoutOutOfRange0))); this.ThrowPending(); return base.Dequeue(timeout, out message); } public IAsyncResult BeginTryReceive(TimeSpan timeout, AsyncCallback callback, object state) { if (timeout < TimeSpan.Zero) throw DiagnosticUtility.ExceptionUtility.ThrowHelperError( new ArgumentOutOfRangeException("timeout", timeout, SR.GetString(SR.SFxTimeoutOutOfRange0))); this.ThrowPending(); return base.BeginDequeue(timeout, callback, state); } public bool EndTryReceive(IAsyncResult result, out Message message) { return base.EndDequeue(result, out message); } public bool WaitForMessage(TimeSpan timeout) { if (timeout < TimeSpan.Zero) throw DiagnosticUtility.ExceptionUtility.ThrowHelperError( new ArgumentOutOfRangeException("timeout", timeout, SR.GetString(SR.SFxTimeoutOutOfRange0))); this.ThrowPending(); return base.WaitForItem(timeout); } public IAsyncResult BeginWaitForMessage(TimeSpan timeout, AsyncCallback callback, object state) { if (timeout < TimeSpan.Zero) throw DiagnosticUtility.ExceptionUtility.ThrowHelperError( new ArgumentOutOfRangeException("timeout", timeout, SR.GetString(SR.SFxTimeoutOutOfRange0))); this.ThrowPending(); return base.BeginWaitForItem(timeout, callback, state); } public bool EndWaitForMessage(IAsyncResult result) { return base.EndWaitForItem(result); } } } // 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
- DataChangedEventManager.cs
- EpmCustomContentWriterNodeData.cs
- UniqueConstraint.cs
- DefaultValueConverter.cs
- SmiRequestExecutor.cs
- SystemMulticastIPAddressInformation.cs
- WebPartCatalogAddVerb.cs
- ObjectStateManager.cs
- PriorityQueue.cs
- ReferentialConstraint.cs
- CalendarTable.cs
- EnumType.cs
- BindingBase.cs
- AccessDataSource.cs
- PresentationTraceSources.cs
- SelectorAutomationPeer.cs
- SqlWebEventProvider.cs
- UIElement3DAutomationPeer.cs
- FormsAuthentication.cs
- ConfigXmlCDataSection.cs
- PackageStore.cs
- CryptographicAttribute.cs
- BamlRecordWriter.cs
- FormatConvertedBitmap.cs
- PagedDataSource.cs
- DisableDpiAwarenessAttribute.cs
- OleDbTransaction.cs
- SQLInt32Storage.cs
- ScriptReferenceBase.cs
- MsmqMessageProperty.cs
- CodeExpressionRuleDeclaration.cs
- SQLGuidStorage.cs
- DbConnectionStringBuilder.cs
- MailMessageEventArgs.cs
- XmlArrayItemAttribute.cs
- Stylus.cs
- SharedPerformanceCounter.cs
- BufferedGraphicsContext.cs
- FileDocument.cs
- CallbackValidatorAttribute.cs
- SpellerInterop.cs
- DiscoveryClientReferences.cs
- LazyTextWriterCreator.cs
- UnmanagedBitmapWrapper.cs
- RelOps.cs
- SystemColors.cs
- PerformanceCounterLib.cs
- HttpListenerPrefixCollection.cs
- OleDbException.cs
- ThreadPool.cs
- PartialTrustVisibleAssembly.cs
- SchemaImporterExtensionElement.cs
- ReadOnlyDictionary.cs
- UnionCodeGroup.cs
- RangeBaseAutomationPeer.cs
- XMLUtil.cs
- MainMenu.cs
- Util.cs
- CryptoHelper.cs
- AsymmetricKeyExchangeDeformatter.cs
- SectionInformation.cs
- StoreContentChangedEventArgs.cs
- SchemaTableOptionalColumn.cs
- ProcessHostFactoryHelper.cs
- DataRow.cs
- AnimationLayer.cs
- ProxyHelper.cs
- Timeline.cs
- DomNameTable.cs
- Char.cs
- ZipIORawDataFileBlock.cs
- SpellerError.cs
- TimeZone.cs
- ISAPIRuntime.cs
- InertiaRotationBehavior.cs
- DesignerResources.cs
- AdapterDictionary.cs
- FontStyleConverter.cs
- ConfigurationPermission.cs
- OLEDB_Util.cs
- ManagedFilter.cs
- SelectedCellsCollection.cs
- LayoutInformation.cs
- DateTimeValueSerializer.cs
- Activator.cs
- TextDecorations.cs
- DataSet.cs
- TextBox.cs
- AlignmentYValidation.cs
- FilteredReadOnlyMetadataCollection.cs
- UICuesEvent.cs
- BigInt.cs
- CollectionDataContractAttribute.cs
- ExpressionStringBuilder.cs
- ContainerTracking.cs
- StorageMappingItemCollection.cs
- PropertyChangedEventManager.cs
- TextDecorationUnitValidation.cs
- SafeNativeMethods.cs
- SkipStoryboardToFill.cs