Code:
/ WCF / WCF / 3.5.30729.1 / untmp / Orcas / SP / ndp / cdf / src / WCF / ServiceModel / System / ServiceModel / Channels / LayeredChannelFactory.cs / 1 / LayeredChannelFactory.cs
//------------------------------------------------------------ // Copyright (c) Microsoft Corporation. All rights reserved. //----------------------------------------------------------- namespace System.ServiceModel.Channels { using System.Collections.Generic; using System.ServiceModel; using System.Diagnostics; using System.IO; using System.Runtime.Serialization; using System.Text; using System.Threading; abstract class LayeredChannelFactory: ChannelFactoryBase { IChannelFactory innerChannelFactory; public LayeredChannelFactory(IDefaultCommunicationTimeouts timeouts, IChannelFactory innerChannelFactory) : base(timeouts) { this.innerChannelFactory = innerChannelFactory; } protected IChannelFactory InnerChannelFactory { get { return this.innerChannelFactory; } } 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 IAsyncResult OnBeginClose(TimeSpan timeout, AsyncCallback callback, object state) { return new ChainedCloseAsyncResult(timeout, callback, state, base.OnBeginClose, base.OnEndClose, this.innerChannelFactory); } protected override void OnEndClose(IAsyncResult result) { ChainedCloseAsyncResult.End(result); } protected override void OnClose(TimeSpan timeout) { TimeoutHelper timeoutHelper = new TimeoutHelper(timeout); base.OnClose(timeoutHelper.RemainingTime()); this.innerChannelFactory.Close(timeoutHelper.RemainingTime()); } protected override void OnOpen(TimeSpan timeout) { this.innerChannelFactory.Open(timeout); } protected override void OnAbort() { base.OnAbort(); this.innerChannelFactory.Abort(); } } abstract class LayeredChannel : ChannelBase where TInnerChannel : class, IChannel { TInnerChannel innerChannel; EventHandler onInnerChannelFaulted; protected LayeredChannel(ChannelManagerBase channelManager, TInnerChannel innerChannel) : base(channelManager) { this.innerChannel = innerChannel; this.onInnerChannelFaulted = new EventHandler(OnInnerChannelFaulted); this.innerChannel.Faulted += this.onInnerChannelFaulted; } protected TInnerChannel InnerChannel { get { return this.innerChannel; } } public override T GetProperty () { T baseProperty = base.GetProperty (); if (baseProperty != null) { return baseProperty; } return this.InnerChannel.GetProperty (); } protected override void OnClosing() { this.innerChannel.Faulted -= this.onInnerChannelFaulted; base.OnClosing(); } protected override void OnAbort() { this.innerChannel.Abort(); } protected override void OnClose(TimeSpan timeout) { this.innerChannel.Close(timeout); } protected override IAsyncResult OnBeginClose(TimeSpan timeout, AsyncCallback callback, object state) { return this.innerChannel.BeginClose(timeout, callback, state); } protected override void OnEndClose(IAsyncResult result) { this.innerChannel.EndClose(result); } protected override void OnOpen(TimeSpan timeout) { this.innerChannel.Open(timeout); } protected override IAsyncResult OnBeginOpen(TimeSpan timeout, AsyncCallback callback, object state) { return this.innerChannel.BeginOpen(timeout, callback, state); } protected override void OnEndOpen(IAsyncResult result) { this.innerChannel.EndOpen(result); } void OnInnerChannelFaulted(object sender, EventArgs e) { this.Fault(); } } class LayeredInputChannel : LayeredChannel , IInputChannel { public LayeredInputChannel(ChannelManagerBase channelManager, IInputChannel innerChannel) : base(channelManager, innerChannel) { } public virtual EndpointAddress LocalAddress { get { return InnerChannel.LocalAddress; } } public Message Receive() { return InnerChannel.Receive(); } public Message Receive(TimeSpan timeout) { return InnerChannel.Receive(timeout); } public IAsyncResult BeginReceive(AsyncCallback callback, object state) { return InnerChannel.BeginReceive(callback, state); } public IAsyncResult BeginReceive(TimeSpan timeout, AsyncCallback callback, object state) { return InnerChannel.BeginReceive(timeout, callback, state); } public Message EndReceive(IAsyncResult result) { return InnerChannel.EndReceive(result); } public IAsyncResult BeginTryReceive(TimeSpan timeout, AsyncCallback callback, object state) { return InnerChannel.BeginTryReceive(timeout, callback, state); } public bool EndTryReceive(IAsyncResult result, out Message message) { return InnerChannel.EndTryReceive(result, out message); } public bool TryReceive(TimeSpan timeout, out Message message) { return InnerChannel.TryReceive(timeout, out message); } public bool WaitForMessage(TimeSpan timeout) { return InnerChannel.WaitForMessage(timeout); } public IAsyncResult BeginWaitForMessage(TimeSpan timeout, AsyncCallback callback, object state) { return InnerChannel.BeginWaitForMessage(timeout, callback, state); } public bool EndWaitForMessage(IAsyncResult result) { return InnerChannel.EndWaitForMessage(result); } } class LayeredDuplexChannel : LayeredInputChannel, IDuplexChannel { IOutputChannel innerOutputChannel; EndpointAddress localAddress; EventHandler onInnerOutputChannelFaulted; public LayeredDuplexChannel(ChannelManagerBase channelManager, IInputChannel innerInputChannel, EndpointAddress localAddress, IOutputChannel innerOutputChannel) : base(channelManager, innerInputChannel) { this.localAddress = localAddress; this.innerOutputChannel = innerOutputChannel; this.onInnerOutputChannelFaulted = new EventHandler(OnInnerOutputChannelFaulted); this.innerOutputChannel.Faulted += this.onInnerOutputChannelFaulted; } public override EndpointAddress LocalAddress { get { return this.localAddress; } } public EndpointAddress RemoteAddress { get { return this.innerOutputChannel.RemoteAddress; } } public Uri Via { get { return innerOutputChannel.Via; } } protected override void OnClosing() { this.innerOutputChannel.Faulted -= this.onInnerOutputChannelFaulted; base.OnClosing(); } protected override void OnAbort() { this.innerOutputChannel.Abort(); base.OnAbort(); } protected override IAsyncResult OnBeginClose(TimeSpan timeout, AsyncCallback callback, object state) { return new ChainedCloseAsyncResult(timeout, callback, state, base.OnBeginClose, base.OnEndClose, this.innerOutputChannel); } protected override void OnEndClose(IAsyncResult result) { ChainedCloseAsyncResult.End(result); } protected override void OnClose(TimeSpan timeout) { TimeoutHelper timeoutHelper = new TimeoutHelper(timeout); this.innerOutputChannel.Close(timeoutHelper.RemainingTime()); base.OnClose(timeoutHelper.RemainingTime()); } protected override IAsyncResult OnBeginOpen(TimeSpan timeout, AsyncCallback callback, object state) { return new ChainedOpenAsyncResult(timeout, callback, state, base.OnBeginOpen, base.OnEndOpen, this.innerOutputChannel); } protected override void OnEndOpen(IAsyncResult result) { ChainedOpenAsyncResult.End(result); } protected override void OnOpen(TimeSpan timeout) { TimeoutHelper timeoutHelper = new TimeoutHelper(timeout); base.OnOpen(timeoutHelper.RemainingTime()); innerOutputChannel.Open(timeoutHelper.RemainingTime()); } public void Send(Message message) { this.Send(message, this.DefaultSendTimeout); } public void Send(Message message, TimeSpan timeout) { this.innerOutputChannel.Send(message, timeout); } 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) { return this.innerOutputChannel.BeginSend(message, timeout, callback, state); } public void EndSend(IAsyncResult result) { this.innerOutputChannel.EndSend(result); } void OnInnerOutputChannelFaulted(object sender, EventArgs e) { this.Fault(); } } } // 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
- SwitchLevelAttribute.cs
- NameScope.cs
- XmlSchemaInfo.cs
- AdobeCFFWrapper.cs
- TextFormatterImp.cs
- JsonEncodingStreamWrapper.cs
- XPathEmptyIterator.cs
- CanonicalizationDriver.cs
- URLString.cs
- MembershipPasswordException.cs
- Compiler.cs
- RestClientProxyHandler.cs
- StorageBasedPackageProperties.cs
- XmlUTF8TextWriter.cs
- FullTrustAssemblyCollection.cs
- RectangleHotSpot.cs
- TimelineGroup.cs
- SQLBoolean.cs
- FlowLayoutSettings.cs
- SettingsPropertyNotFoundException.cs
- Types.cs
- EntityAdapter.cs
- GlyphingCache.cs
- WorkflowApplicationCompletedException.cs
- TextEditorCharacters.cs
- ControlType.cs
- DynamicDataRouteHandler.cs
- HttpSocketManager.cs
- SamlSecurityTokenAuthenticator.cs
- KeyFrames.cs
- CharacterString.cs
- QueryStoreStatusRequest.cs
- MaterialGroup.cs
- Thumb.cs
- WindowsGraphicsWrapper.cs
- XXXOnTypeBuilderInstantiation.cs
- OdbcParameterCollection.cs
- BoundingRectTracker.cs
- IxmlLineInfo.cs
- EmptyEnumerator.cs
- LinqDataSourceSelectEventArgs.cs
- ApplicationDirectoryMembershipCondition.cs
- TextEditorThreadLocalStore.cs
- RankException.cs
- IDQuery.cs
- ByteAnimationBase.cs
- FileSecurity.cs
- UndirectedGraph.cs
- SingleAnimationBase.cs
- EmptyTextWriter.cs
- SafeNativeMethods.cs
- ValidationHelpers.cs
- SemanticResolver.cs
- ServiceHost.cs
- Addressing.cs
- RowUpdatingEventArgs.cs
- ConsumerConnectionPoint.cs
- Paragraph.cs
- BindingWorker.cs
- Control.cs
- StringAnimationBase.cs
- WpfPayload.cs
- Viewport3DVisual.cs
- MenuCommandService.cs
- sqlpipe.cs
- DocumentXPathNavigator.cs
- mediaeventshelper.cs
- ValidationRuleCollection.cs
- DLinqColumnProvider.cs
- ActivityScheduledQuery.cs
- ReverseInheritProperty.cs
- ToolStripProfessionalLowResolutionRenderer.cs
- QilIterator.cs
- InstanceCreationEditor.cs
- TextParagraphView.cs
- RequestCacheManager.cs
- MemberDescriptor.cs
- BlurBitmapEffect.cs
- LineInfo.cs
- OleDbEnumerator.cs
- TableCellCollection.cs
- Object.cs
- SafeRightsManagementSessionHandle.cs
- GrammarBuilderPhrase.cs
- ValidationErrorCollection.cs
- SecurityContext.cs
- UnmanagedHandle.cs
- MetadataArtifactLoaderComposite.cs
- Knowncolors.cs
- DesignerTransactionCloseEvent.cs
- SerializationInfoEnumerator.cs
- ContainerSelectorGlyph.cs
- StreamUpgradeBindingElement.cs
- SimpleFileLog.cs
- SystemBrushes.cs
- XmlStreamNodeWriter.cs
- ChannelServices.cs
- ServicePointManager.cs
- NetworkStream.cs
- PolyBezierSegmentFigureLogic.cs