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
- IncrementalCompileAnalyzer.cs
- TextMetrics.cs
- DetailsViewRow.cs
- TransferRequestHandler.cs
- handlecollector.cs
- SortQuery.cs
- CellCreator.cs
- Enum.cs
- Command.cs
- TextViewBase.cs
- MemberExpressionHelper.cs
- DataGridViewColumnCollection.cs
- ObjectQueryProvider.cs
- XslCompiledTransform.cs
- DesignerTextViewAdapter.cs
- TemplateBindingExtensionConverter.cs
- TemplateContentLoader.cs
- PageMediaSize.cs
- BuildResultCache.cs
- ChannelPoolSettingsElement.cs
- RangeEnumerable.cs
- Repeater.cs
- AppDomainUnloadedException.cs
- XmlSchemaAll.cs
- elementinformation.cs
- DataKeyArray.cs
- ScriptRegistrationManager.cs
- XPathNodeHelper.cs
- AccessKeyManager.cs
- ReturnType.cs
- Comparer.cs
- SparseMemoryStream.cs
- WebPartPersonalization.cs
- Application.cs
- Serializer.cs
- HtmlTextArea.cs
- NativeMethods.cs
- ConfigurationLocation.cs
- StrokeCollectionDefaultValueFactory.cs
- ObjectKeyFrameCollection.cs
- CacheDependency.cs
- FakeModelItemImpl.cs
- DataControlFieldHeaderCell.cs
- UriWriter.cs
- TcpChannelFactory.cs
- PersonalizationAdministration.cs
- ProxyElement.cs
- ObjRef.cs
- PropertyValueEditor.cs
- SqlConnectionStringBuilder.cs
- KeyedHashAlgorithm.cs
- AttributeUsageAttribute.cs
- NumericUpDownAccelerationCollection.cs
- EntityProxyTypeInfo.cs
- Geometry3D.cs
- HtmlElement.cs
- XslTransform.cs
- RegisteredHiddenField.cs
- ExpressionBuilder.cs
- HandlerBase.cs
- BinaryKeyIdentifierClause.cs
- HtmlImageAdapter.cs
- XmlSerializationGeneratedCode.cs
- EntityContainerEntitySet.cs
- TypeHelpers.cs
- AutoGeneratedField.cs
- cache.cs
- SqlProfileProvider.cs
- latinshape.cs
- ObjectListDesigner.cs
- DrawListViewItemEventArgs.cs
- BoundColumn.cs
- dbdatarecord.cs
- DataColumnMapping.cs
- NotEqual.cs
- ApplyHostConfigurationBehavior.cs
- PreviewKeyDownEventArgs.cs
- FixedSOMPageConstructor.cs
- MailAddress.cs
- HatchBrush.cs
- XmlBufferReader.cs
- TemplateParser.cs
- CustomTypeDescriptor.cs
- BoundPropertyEntry.cs
- RectangleF.cs
- FrameAutomationPeer.cs
- Separator.cs
- keycontainerpermission.cs
- FolderBrowserDialog.cs
- ArraySortHelper.cs
- StoreUtilities.cs
- PrimitiveXmlSerializers.cs
- XmlILOptimizerVisitor.cs
- ScriptingProfileServiceSection.cs
- NativeMethodsOther.cs
- UidPropertyAttribute.cs
- RawTextInputReport.cs
- WaitHandleCannotBeOpenedException.cs
- MaskedTextBoxTextEditor.cs
- XmlDataDocument.cs