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
- WmiPutTraceRecord.cs
- EmbeddedObject.cs
- TemplatedMailWebEventProvider.cs
- xamlnodes.cs
- MenuItemBinding.cs
- WpfPayload.cs
- XsltOutput.cs
- SafeNativeMemoryHandle.cs
- InputMethod.cs
- TypeDescriptor.cs
- PassportAuthentication.cs
- SafeWaitHandle.cs
- XappLauncher.cs
- RedistVersionInfo.cs
- BigInt.cs
- LineInfo.cs
- FontStyle.cs
- UserNameSecurityTokenProvider.cs
- ConfigDefinitionUpdates.cs
- ProcessRequestAsyncResult.cs
- SwitchAttribute.cs
- BlurBitmapEffect.cs
- Baml6Assembly.cs
- SmtpClient.cs
- HttpModuleAction.cs
- ImageListStreamer.cs
- ParentControlDesigner.cs
- HMACMD5.cs
- GestureRecognitionResult.cs
- PeerPresenceInfo.cs
- TypeConverter.cs
- SmtpLoginAuthenticationModule.cs
- WindowsGraphicsCacheManager.cs
- WebPartEditorCancelVerb.cs
- AssemblyInfo.cs
- __ComObject.cs
- SelectedCellsChangedEventArgs.cs
- SegmentInfo.cs
- XmlSchemaObjectTable.cs
- RegistryPermission.cs
- KerberosRequestorSecurityToken.cs
- GridViewRowCollection.cs
- SHA256.cs
- RelationshipSet.cs
- QueueProcessor.cs
- EntityProxyTypeInfo.cs
- Control.cs
- shaperfactoryquerycacheentry.cs
- BooleanKeyFrameCollection.cs
- FixedFindEngine.cs
- SvcMapFileSerializer.cs
- InvalidateEvent.cs
- RIPEMD160Managed.cs
- CheckBoxBaseAdapter.cs
- SplitterPanel.cs
- AsyncDataRequest.cs
- ModuleConfigurationInfo.cs
- SetterBase.cs
- ChildDocumentBlock.cs
- PageParser.cs
- XComponentModel.cs
- ChildrenQuery.cs
- Suspend.cs
- AuthenticationSection.cs
- TextSelectionProcessor.cs
- TransactionBehavior.cs
- ZipIOEndOfCentralDirectoryBlock.cs
- ArglessEventHandlerProxy.cs
- AssemblyInfo.cs
- IsolatedStorageFile.cs
- JpegBitmapDecoder.cs
- ColumnPropertiesGroup.cs
- BaseTypeViewSchema.cs
- TabPage.cs
- AdRotator.cs
- HtmlTableCell.cs
- TrackingStringDictionary.cs
- DataServiceSaveChangesEventArgs.cs
- TransformerInfoCollection.cs
- XmlElementAttributes.cs
- CommonGetThemePartSize.cs
- EntityDataSourceSelectedEventArgs.cs
- UserPreferenceChangingEventArgs.cs
- System.Data_BID.cs
- DrawTreeNodeEventArgs.cs
- PrinterResolution.cs
- ConfigXmlDocument.cs
- UserControl.cs
- TagPrefixCollection.cs
- FontFamilyConverter.cs
- MgmtConfigurationRecord.cs
- BlurBitmapEffect.cs
- XmlQueryStaticData.cs
- Evidence.cs
- RoleBoolean.cs
- DbMetaDataCollectionNames.cs
- StubHelpers.cs
- BadImageFormatException.cs
- InkCanvasFeedbackAdorner.cs
- BitmapEffectrendercontext.cs