Code:
/ WCF / WCF / 3.5.30729.1 / untmp / Orcas / SP / ndp / cdf / src / WCF / ServiceModel / System / ServiceModel / Channels / NamedPipeChannelListener.cs / 1 / NamedPipeChannelListener.cs
//------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//-----------------------------------------------------------
namespace System.ServiceModel.Channels
{
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Diagnostics;
using System.IO;
using System.Runtime.Serialization;
using System.Text;
using System.Threading;
using System.Security.Principal;
using System.ServiceModel;
using System.ServiceModel.Diagnostics;
abstract class NamedPipeChannelListener
: NamedPipeChannelListener, IChannelListener
where TChannel : class, IChannel
where TChannelAcceptor : ChannelAcceptor
{
protected NamedPipeChannelListener(NamedPipeTransportBindingElement bindingElement, BindingContext context)
: base(bindingElement, context)
{
}
protected abstract TChannelAcceptor ChannelAcceptor { get; }
protected override void OnOpen(TimeSpan timeout)
{
TimeoutHelper timeoutHelper = new TimeoutHelper(timeout);
base.OnOpen(timeoutHelper.RemainingTime());
ChannelAcceptor.Open(timeoutHelper.RemainingTime());
}
protected override IAsyncResult OnBeginOpen(TimeSpan timeout, AsyncCallback callback, object state)
{
return new ChainedOpenAsyncResult(timeout, callback, state, base.OnBeginOpen, base.OnEndOpen, ChannelAcceptor);
}
protected override void OnEndOpen(IAsyncResult result)
{
ChainedOpenAsyncResult.End(result);
}
protected override void OnClose(TimeSpan timeout)
{
TimeoutHelper timeoutHelper = new TimeoutHelper(timeout);
ChannelAcceptor.Close(timeoutHelper.RemainingTime());
base.OnClose(timeoutHelper.RemainingTime());
}
protected override void OnAbort()
{
this.ChannelAcceptor.Abort();
base.OnAbort();
}
protected override IAsyncResult OnBeginClose(TimeSpan timeout, AsyncCallback callback, object state)
{
return new ChainedCloseAsyncResult(timeout, callback, state, base.OnBeginClose, base.OnEndClose, ChannelAcceptor);
}
protected override void OnEndClose(IAsyncResult result)
{
ChainedCloseAsyncResult.End(result);
}
public TChannel AcceptChannel()
{
return this.AcceptChannel(this.DefaultReceiveTimeout);
}
public IAsyncResult BeginAcceptChannel(AsyncCallback callback, object state)
{
return this.BeginAcceptChannel(this.DefaultReceiveTimeout, callback, state);
}
public TChannel AcceptChannel(TimeSpan timeout)
{
base.ThrowIfNotOpened();
return ChannelAcceptor.AcceptChannel(timeout);
}
public IAsyncResult BeginAcceptChannel(TimeSpan timeout, AsyncCallback callback, object state)
{
base.ThrowIfNotOpened();
return ChannelAcceptor.BeginAcceptChannel(timeout, callback, state);
}
public TChannel EndAcceptChannel(IAsyncResult result)
{
base.ThrowPending();
return ChannelAcceptor.EndAcceptChannel(result);
}
protected override bool OnWaitForChannel(TimeSpan timeout)
{
return ChannelAcceptor.WaitForChannel(timeout);
}
protected override IAsyncResult OnBeginWaitForChannel(TimeSpan timeout, AsyncCallback callback, object state)
{
return ChannelAcceptor.BeginWaitForChannel(timeout, callback, state);
}
protected override bool OnEndWaitForChannel(IAsyncResult result)
{
return ChannelAcceptor.EndWaitForChannel(result);
}
}
class NamedPipeReplyChannelListener
: NamedPipeChannelListener
, ISingletonChannelListener
{
ReplyChannelAcceptor replyAcceptor;
public NamedPipeReplyChannelListener(NamedPipeTransportBindingElement bindingElement, BindingContext context)
: base(bindingElement, context)
{
this.replyAcceptor = new ConnectionOrientedTransportReplyChannelAcceptor(this);
}
protected override ReplyChannelAcceptor ChannelAcceptor
{
get { return this.replyAcceptor; }
}
TimeSpan ISingletonChannelListener.ReceiveTimeout
{
get { return this.InternalReceiveTimeout; }
}
void ISingletonChannelListener.ReceiveRequest(RequestContext requestContext, ItemDequeuedCallback callback, bool canDispatchOnThisThread)
{
if (DiagnosticUtility.ShouldTraceVerbose)
{
TraceUtility.TraceEvent(TraceEventType.Verbose, MessageReceivedTraceCode, requestContext.RequestMessage);
}
replyAcceptor.Enqueue(requestContext, callback, canDispatchOnThisThread);
}
}
class NamedPipeDuplexChannelListener
: NamedPipeChannelListener>
, ISessionPreambleHandler
{
InputQueueChannelAcceptor duplexAcceptor;
public NamedPipeDuplexChannelListener(NamedPipeTransportBindingElement bindingElement, BindingContext context)
: base(bindingElement, context)
{
this.duplexAcceptor = new InputQueueChannelAcceptor(this);
}
protected override InputQueueChannelAcceptor ChannelAcceptor
{
get { return this.duplexAcceptor; }
}
void ISessionPreambleHandler.HandleServerSessionPreamble(ServerSessionPreambleConnectionReader preambleReader,
ConnectionDemuxer connectionDemuxer)
{
IDuplexSessionChannel channel = preambleReader.CreateDuplexSessionChannel(
this, new EndpointAddress(this.Uri), ExposeConnectionProperty, connectionDemuxer);
duplexAcceptor.EnqueueAndDispatch(channel, preambleReader.ConnectionDequeuedCallback);
}
}
abstract class NamedPipeChannelListener : ConnectionOrientedTransportChannelListener
{
List allowedUsers;
protected NamedPipeChannelListener(NamedPipeTransportBindingElement bindingElement, BindingContext context)
: base(bindingElement, context)
{
SetIdleTimeout(bindingElement.ConnectionPoolSettings.IdleTimeout);
SetMaxPooledConnections(bindingElement.ConnectionPoolSettings.MaxOutboundConnectionsPerEndpoint);
}
static UriPrefixTable transportManagerTable =
new UriPrefixTable();
public override string Scheme
{
get { return Uri.UriSchemeNetPipe; }
}
internal List AllowedUsers
{
get
{
return allowedUsers;
}
set
{
lock (ThisLock)
{
ThrowIfDisposedOrImmutable();
this.allowedUsers = value;
}
}
}
internal override TraceCode MessageReceivedTraceCode
{
get { return TraceCode.NamedPipeChannelMessageReceived; }
}
internal override TraceCode MessageReceiveFailedTraceCode
{
get { return TraceCode.NamedPipeChannelMessageReceiveFailed; }
}
internal static UriPrefixTable StaticTransportManagerTable
{
get
{
return transportManagerTable;
}
}
internal override UriPrefixTable TransportManagerTable
{
get
{
return transportManagerTable;
}
}
internal override ITransportManagerRegistration CreateTransportManagerRegistration(Uri listenUri)
{
return new ExclusiveNamedPipeTransportManager(listenUri, this);
}
protected override bool SupportsUpgrade(StreamUpgradeBindingElement upgradeBindingElement)
{
return !(upgradeBindingElement is SslStreamSecurityBindingElement);
}
}
}
// 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
- ConstructorNeedsTagAttribute.cs
- QueryRewriter.cs
- Padding.cs
- __ComObject.cs
- FieldReference.cs
- ProtocolsInstallComponent.cs
- ValidationHelper.cs
- Pointer.cs
- RectAnimation.cs
- SamlAuthorityBinding.cs
- TraceLevelStore.cs
- TextServicesPropertyRanges.cs
- Buffer.cs
- AlgoModule.cs
- LOSFormatter.cs
- EncryptedReference.cs
- WinFormsUtils.cs
- LinqDataSourceValidationException.cs
- EllipseGeometry.cs
- Authorization.cs
- EditBehavior.cs
- Delegate.cs
- ToolStripArrowRenderEventArgs.cs
- HtmlInputButton.cs
- mansign.cs
- InitiatorSessionSymmetricMessageSecurityProtocol.cs
- ISFClipboardData.cs
- COM2ComponentEditor.cs
- DoubleConverter.cs
- base64Transforms.cs
- BufferAllocator.cs
- Misc.cs
- FreeFormPanel.cs
- PropertyTab.cs
- MailDefinition.cs
- TreeNode.cs
- PropertyPath.cs
- RelatedImageListAttribute.cs
- ServicePerformanceCounters.cs
- DBParameter.cs
- AutomationPropertyInfo.cs
- VBCodeProvider.cs
- TypeNameConverter.cs
- ThousandthOfEmRealDoubles.cs
- StylusPointProperty.cs
- OdbcDataReader.cs
- TypeSemantics.cs
- XPathArrayIterator.cs
- Keyboard.cs
- IsolatedStorageFilePermission.cs
- ViewValidator.cs
- VariableQuery.cs
- OrderedDictionaryStateHelper.cs
- CodeCastExpression.cs
- ContractMapping.cs
- ACE.cs
- embossbitmapeffect.cs
- Rect.cs
- UnicastIPAddressInformationCollection.cs
- Size3DConverter.cs
- DescendentsWalkerBase.cs
- Encoding.cs
- FilterQuery.cs
- _NetworkingPerfCounters.cs
- Expression.DebuggerProxy.cs
- RegexRunner.cs
- KnownAssemblyEntry.cs
- SmiEventSink_DeferedProcessing.cs
- StylusPointPropertyUnit.cs
- Opcode.cs
- BackgroundWorker.cs
- AbstractExpressions.cs
- FormViewPagerRow.cs
- PointConverter.cs
- ControlAdapter.cs
- SolidColorBrush.cs
- CompositeFontInfo.cs
- CodeDOMProvider.cs
- JoinGraph.cs
- MemberPath.cs
- AppearanceEditorPart.cs
- AppendHelper.cs
- UInt64Storage.cs
- DbConvert.cs
- ServiceObjectContainer.cs
- RotateTransform.cs
- SendAgentStatusRequest.cs
- httpserverutility.cs
- OutputCacheProfile.cs
- InteropTrackingRecord.cs
- DecoderBestFitFallback.cs
- InvalidEnumArgumentException.cs
- EditingCommands.cs
- CharEnumerator.cs
- WebPartCollection.cs
- CryptoStream.cs
- Property.cs
- PagesSection.cs
- CodeSnippetStatement.cs
- DataListItem.cs