Code:
/ WCF / WCF / 3.5.30729.1 / untmp / Orcas / SP / ndp / cdf / src / WCF / ServiceModel / System / ServiceModel / Dispatcher / ListenerBinder.cs / 1 / ListenerBinder.cs
//------------------------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//-----------------------------------------------------------------------------
namespace System.ServiceModel.Dispatcher
{
using System;
using System.ServiceModel.Channels;
static class ListenerBinder
{
internal static IListenerBinder GetBinder(IChannelListener listener, MessageVersion messageVersion)
{
IChannelListener input = listener as IChannelListener;
if (input != null)
return new InputListenerBinder(input, messageVersion);
IChannelListener inputSession = listener as IChannelListener;
if (inputSession != null)
return new InputSessionListenerBinder(inputSession, messageVersion);
IChannelListener reply = listener as IChannelListener;
if (reply != null)
return new ReplyListenerBinder(reply, messageVersion);
IChannelListener replySession = listener as IChannelListener;
if (replySession != null)
return new ReplySessionListenerBinder(replySession, messageVersion);
IChannelListener duplex = listener as IChannelListener;
if (duplex != null)
return new DuplexListenerBinder(duplex, messageVersion);
IChannelListener duplexSession = listener as IChannelListener;
if (duplexSession != null)
return new DuplexSessionListenerBinder(duplexSession, messageVersion);
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.GetString(SR.UnknownListenerType1, listener.Uri.AbsoluteUri)));
}
// -----------------------------------------------------------------------------------------------------------
// Listener Binders
class DuplexListenerBinder : IListenerBinder
{
IRequestReplyCorrelator correlator;
IChannelListener listener;
MessageVersion messageVersion;
internal DuplexListenerBinder(IChannelListener listener, MessageVersion messageVersion)
{
this.correlator = new RequestReplyCorrelator();
this.listener = listener;
this.messageVersion = messageVersion;
}
public IChannelListener Listener
{
get { return this.listener; }
}
public MessageVersion MessageVersion
{
get { return this.messageVersion; }
}
public IChannelBinder Accept(TimeSpan timeout)
{
IDuplexChannel channel = this.listener.AcceptChannel(timeout);
if (channel == null)
return null;
return new DuplexChannelBinder(channel, this.correlator, this.listener.Uri);
}
public IAsyncResult BeginAccept(TimeSpan timeout, AsyncCallback callback, object state)
{
return this.listener.BeginAcceptChannel(timeout, callback, state);
}
public IChannelBinder EndAccept(IAsyncResult result)
{
IDuplexChannel channel = this.listener.EndAcceptChannel(result);
if (channel == null)
return null;
return new DuplexChannelBinder(channel, this.correlator, this.listener.Uri);
}
}
class DuplexSessionListenerBinder : IListenerBinder
{
IRequestReplyCorrelator correlator;
IChannelListener listener;
MessageVersion messageVersion;
internal DuplexSessionListenerBinder(IChannelListener listener, MessageVersion messageVersion)
{
this.correlator = new RequestReplyCorrelator();
this.listener = listener;
this.messageVersion = messageVersion;
}
public IChannelListener Listener
{
get { return this.listener; }
}
public MessageVersion MessageVersion
{
get { return this.messageVersion; }
}
public IChannelBinder Accept(TimeSpan timeout)
{
IDuplexSessionChannel channel = this.listener.AcceptChannel(timeout);
if (channel == null)
return null;
return new DuplexChannelBinder(channel, this.correlator, this.listener.Uri);
}
public IAsyncResult BeginAccept(TimeSpan timeout, AsyncCallback callback, object state)
{
return this.listener.BeginAcceptChannel(timeout, callback, state);
}
public IChannelBinder EndAccept(IAsyncResult result)
{
IDuplexSessionChannel channel = this.listener.EndAcceptChannel(result);
if (channel == null)
return null;
return new DuplexChannelBinder(channel, this.correlator, this.listener.Uri);
}
}
class InputListenerBinder : IListenerBinder
{
IChannelListener listener;
MessageVersion messageVersion;
internal InputListenerBinder(IChannelListener listener, MessageVersion messageVersion)
{
this.listener = listener;
this.messageVersion = messageVersion;
}
public IChannelListener Listener
{
get { return this.listener; }
}
public MessageVersion MessageVersion
{
get { return this.messageVersion; }
}
public IChannelBinder Accept(TimeSpan timeout)
{
IInputChannel channel = this.listener.AcceptChannel(timeout);
if (channel == null)
return null;
return new InputChannelBinder(channel, this.listener.Uri);
}
public IAsyncResult BeginAccept(TimeSpan timeout, AsyncCallback callback, object state)
{
return this.listener.BeginAcceptChannel(timeout, callback, state);
}
public IChannelBinder EndAccept(IAsyncResult result)
{
IInputChannel channel = this.listener.EndAcceptChannel(result);
if (channel == null)
return null;
return new InputChannelBinder(channel, this.listener.Uri);
}
}
class InputSessionListenerBinder : IListenerBinder
{
IChannelListener listener;
MessageVersion messageVersion;
internal InputSessionListenerBinder(IChannelListener listener, MessageVersion messageVersion)
{
this.listener = listener;
this.messageVersion = messageVersion;
}
public IChannelListener Listener
{
get { return this.listener; }
}
public MessageVersion MessageVersion
{
get { return this.messageVersion; }
}
public IChannelBinder Accept(TimeSpan timeout)
{
IInputSessionChannel channel = this.listener.AcceptChannel(timeout);
if (null == channel)
return null;
return new InputChannelBinder(channel, this.listener.Uri);
}
public IAsyncResult BeginAccept(TimeSpan timeout, AsyncCallback callback, object state)
{
return this.listener.BeginAcceptChannel(timeout, callback, state);
}
public IChannelBinder EndAccept(IAsyncResult result)
{
IInputSessionChannel channel = this.listener.EndAcceptChannel(result);
if (channel == null)
return null;
return new InputChannelBinder(channel, this.listener.Uri);
}
}
class ReplyListenerBinder : IListenerBinder
{
IChannelListener listener;
MessageVersion messageVersion;
internal ReplyListenerBinder(IChannelListener listener, MessageVersion messageVersion)
{
this.listener = listener;
this.messageVersion = messageVersion;
}
public IChannelListener Listener
{
get { return this.listener; }
}
public MessageVersion MessageVersion
{
get { return this.messageVersion; }
}
public IChannelBinder Accept(TimeSpan timeout)
{
IReplyChannel channel = this.listener.AcceptChannel(timeout);
if (channel == null)
return null;
return new ReplyChannelBinder(channel, listener.Uri);
}
public IAsyncResult BeginAccept(TimeSpan timeout, AsyncCallback callback, object state)
{
return this.listener.BeginAcceptChannel(timeout, callback, state);
}
public IChannelBinder EndAccept(IAsyncResult result)
{
IReplyChannel channel = this.listener.EndAcceptChannel(result);
if (channel == null)
return null;
return new ReplyChannelBinder(channel, listener.Uri);
}
}
class ReplySessionListenerBinder : IListenerBinder
{
IChannelListener listener;
MessageVersion messageVersion;
internal ReplySessionListenerBinder(IChannelListener listener, MessageVersion messageVersion)
{
this.listener = listener;
this.messageVersion = messageVersion;
}
public IChannelListener Listener
{
get { return this.listener; }
}
public MessageVersion MessageVersion
{
get { return this.messageVersion; }
}
public IChannelBinder Accept(TimeSpan timeout)
{
IReplySessionChannel channel = this.listener.AcceptChannel(timeout);
if (channel == null)
return null;
return new ReplyChannelBinder(channel, listener.Uri);
}
public IAsyncResult BeginAccept(TimeSpan timeout, AsyncCallback callback, object state)
{
return this.listener.BeginAcceptChannel(timeout, callback, state);
}
public IChannelBinder EndAccept(IAsyncResult result)
{
IReplySessionChannel channel = this.listener.EndAcceptChannel(result);
if (channel == null)
return null;
return new ReplyChannelBinder(channel, listener.Uri);
}
}
}
}
// 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
- StrokeFIndices.cs
- XMLSyntaxException.cs
- DrawingAttributeSerializer.cs
- MergablePropertyAttribute.cs
- DataTemplateSelector.cs
- Switch.cs
- InstanceContextMode.cs
- Quad.cs
- recordstate.cs
- X509Certificate2.cs
- SerializationSectionGroup.cs
- ToolStripGripRenderEventArgs.cs
- GridItemPatternIdentifiers.cs
- RegexInterpreter.cs
- WebPartConnectVerb.cs
- DataGridViewHitTestInfo.cs
- ValueTypePropertyReference.cs
- TakeQueryOptionExpression.cs
- HashHelper.cs
- SafePEFileHandle.cs
- WasAdminWrapper.cs
- TextBoxAutoCompleteSourceConverter.cs
- CreateUserWizardStep.cs
- NameNode.cs
- SendMessageChannelCache.cs
- COM2TypeInfoProcessor.cs
- TemplateBindingExtension.cs
- TextElementCollection.cs
- MatrixTransform3D.cs
- XPathExpr.cs
- CharKeyFrameCollection.cs
- TimeEnumHelper.cs
- ScriptDescriptor.cs
- EntityDataSourceEntitySetNameItem.cs
- Update.cs
- SqlNode.cs
- IdentityNotMappedException.cs
- QuadraticBezierSegment.cs
- ByteArrayHelperWithString.cs
- CalendarButtonAutomationPeer.cs
- StorageInfo.cs
- SerializableAttribute.cs
- XmlEncodedRawTextWriter.cs
- PtsCache.cs
- HttpProfileBase.cs
- UnsafeNativeMethods.cs
- LeftCellWrapper.cs
- BrowserTree.cs
- NetworkCredential.cs
- BufferBuilder.cs
- WriteLine.cs
- Int32Rect.cs
- RegistrySecurity.cs
- SQLConvert.cs
- RootBrowserWindow.cs
- DataGridViewCellValidatingEventArgs.cs
- DeviceFiltersSection.cs
- SoapIncludeAttribute.cs
- WebControlsSection.cs
- InstanceValue.cs
- CodeGenerator.cs
- TypefaceMap.cs
- NotifyParentPropertyAttribute.cs
- SqlCacheDependencyDatabase.cs
- FeatureSupport.cs
- WebPartDisplayModeCancelEventArgs.cs
- FixedPageProcessor.cs
- BitmapEffect.cs
- HttpProcessUtility.cs
- ImageBrush.cs
- UnsafeNativeMethods.cs
- processwaithandle.cs
- ComponentManagerBroker.cs
- TextTreeFixupNode.cs
- IntranetCredentialPolicy.cs
- Cursor.cs
- RowToFieldTransformer.cs
- DivideByZeroException.cs
- RevocationPoint.cs
- Pen.cs
- RightsManagementPermission.cs
- WindowsListView.cs
- AuthenticationService.cs
- PeerCollaborationPermission.cs
- SetStoryboardSpeedRatio.cs
- BrowserCapabilitiesCompiler.cs
- SqlTriggerAttribute.cs
- SchemaDeclBase.cs
- TableLayoutCellPaintEventArgs.cs
- GuidelineCollection.cs
- ImageDrawing.cs
- DataTableReader.cs
- CorrelationService.cs
- TreeNodeStyleCollection.cs
- PreservationFileWriter.cs
- ContentPresenter.cs
- baseaxisquery.cs
- FlagsAttribute.cs
- RemotingConfigParser.cs
- DataBoundLiteralControl.cs