Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / cdf / src / WCF / WasHosting / System / ServiceModel / WasHosting / BaseProcessProtocolHandler.cs / 1305376 / BaseProcessProtocolHandler.cs
//---------------------------------------------------------------------------- // Copyright (c) Microsoft Corporation. All rights reserved. //--------------------------------------------------------------------------- namespace System.ServiceModel.WasHosting { using System; using System.Collections.Generic; using System.Diagnostics; using System.Diagnostics.CodeAnalysis; using System.ServiceModel; using System.Web; using System.Web.Hosting; using System.ServiceModel.Channels; using System.ServiceModel.Activation; using System.Runtime; abstract class BaseProcessProtocolHandler : ProcessProtocolHandler { string protocolId; IAdphManager adphManager; // Mapping from listenerChannelId->listenerChannelContext (i.e. IAdphManager, appId) DictionarylistenerChannelIdMapping = new Dictionary (); [SuppressMessage(FxCop.Category.Performance, FxCop.Rule.AvoidUncalledPrivateCode, Justification = "Instantiated by ASP.NET")] protected BaseProcessProtocolHandler(string protocolId) : base() { this.protocolId = protocolId; } internal virtual void HandleStartListenerChannelError(IListenerChannelCallback listenerChannelCallback, Exception ex) { // This is the workaround to let WAS know that the LC is started and then gracefully stopped. listenerChannelCallback.ReportStarted(); listenerChannelCallback.ReportStopped(0); } // Start per-process listening for messages public override void StartListenerChannel(IListenerChannelCallback listenerChannelCallback, IAdphManager adphManager) { DiagnosticUtility.DebugAssert(listenerChannelCallback != null, "The listenerChannelCallback parameter must not be null"); DiagnosticUtility.DebugAssert(adphManager != null, "The adphManager parameter must not be null"); int channelId = listenerChannelCallback.GetId(); ListenerChannelContext listenerChannelContext; lock (this.listenerChannelIdMapping) { if (!listenerChannelIdMapping.TryGetValue(channelId, out listenerChannelContext)) { int listenerChannelDataLength = listenerChannelCallback.GetBlobLength(); byte[] listenerChannelData = new byte[listenerChannelDataLength]; listenerChannelCallback.GetBlob(listenerChannelData, ref listenerChannelDataLength); Debug.Print("BaseProcessProtocolHandler.StartListenerChannel() GetBlob() contains " + listenerChannelDataLength + " bytes"); listenerChannelContext = ListenerChannelContext.Hydrate(listenerChannelData); this.listenerChannelIdMapping.Add(channelId, listenerChannelContext); Debug.Print("BaseProcessProtocolHandler.StartListenerChannel() listenerChannelContext.ListenerChannelId: " + listenerChannelContext.ListenerChannelId); } } if (this.adphManager == null) { this.adphManager = adphManager; } try { // wether or not a previous AppDomain was running, we're going to start a new one now: Debug.Print("BaseProcessProtocolHandler.StartListenerChannel() calling StartAppDomainProtocolListenerChannel(appKey:" + listenerChannelContext.AppKey + " protocolId:" + protocolId + ")"); adphManager.StartAppDomainProtocolListenerChannel(listenerChannelContext.AppKey, protocolId, listenerChannelCallback); } catch (Exception ex) { if (Fx.IsFatal(ex)) { throw; } if (DiagnosticUtility.ShouldTraceError) { DiagnosticUtility.ExceptionUtility.TraceHandledException(ex, TraceEventType.Error); } HandleStartListenerChannelError(listenerChannelCallback, ex); } } public override void StopProtocol(bool immediate) { Debug.Print("BaseProcessProtocolHandler.StopProtocol(protocolId:" + protocolId + ", immediate:" + immediate + ")"); } public override void StopListenerChannel(int listenerChannelId, bool immediate) { Debug.Print("BaseProcessProtocolHandler.StopListenerChannel(protocolId:" + protocolId + ", listenerChannelId:" + listenerChannelId + ", immediate:" + immediate + ")"); ListenerChannelContext listenerChannelContext = this.listenerChannelIdMapping[listenerChannelId]; adphManager.StopAppDomainProtocolListenerChannel(listenerChannelContext.AppKey, protocolId, listenerChannelId, immediate); lock (this.listenerChannelIdMapping) { // Remove the channel id. this.listenerChannelIdMapping.Remove(listenerChannelId); } } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. //---------------------------------------------------------------------------- // Copyright (c) Microsoft Corporation. All rights reserved. //--------------------------------------------------------------------------- namespace System.ServiceModel.WasHosting { using System; using System.Collections.Generic; using System.Diagnostics; using System.Diagnostics.CodeAnalysis; using System.ServiceModel; using System.Web; using System.Web.Hosting; using System.ServiceModel.Channels; using System.ServiceModel.Activation; using System.Runtime; abstract class BaseProcessProtocolHandler : ProcessProtocolHandler { string protocolId; IAdphManager adphManager; // Mapping from listenerChannelId->listenerChannelContext (i.e. IAdphManager, appId) Dictionary listenerChannelIdMapping = new Dictionary (); [SuppressMessage(FxCop.Category.Performance, FxCop.Rule.AvoidUncalledPrivateCode, Justification = "Instantiated by ASP.NET")] protected BaseProcessProtocolHandler(string protocolId) : base() { this.protocolId = protocolId; } internal virtual void HandleStartListenerChannelError(IListenerChannelCallback listenerChannelCallback, Exception ex) { // This is the workaround to let WAS know that the LC is started and then gracefully stopped. listenerChannelCallback.ReportStarted(); listenerChannelCallback.ReportStopped(0); } // Start per-process listening for messages public override void StartListenerChannel(IListenerChannelCallback listenerChannelCallback, IAdphManager adphManager) { DiagnosticUtility.DebugAssert(listenerChannelCallback != null, "The listenerChannelCallback parameter must not be null"); DiagnosticUtility.DebugAssert(adphManager != null, "The adphManager parameter must not be null"); int channelId = listenerChannelCallback.GetId(); ListenerChannelContext listenerChannelContext; lock (this.listenerChannelIdMapping) { if (!listenerChannelIdMapping.TryGetValue(channelId, out listenerChannelContext)) { int listenerChannelDataLength = listenerChannelCallback.GetBlobLength(); byte[] listenerChannelData = new byte[listenerChannelDataLength]; listenerChannelCallback.GetBlob(listenerChannelData, ref listenerChannelDataLength); Debug.Print("BaseProcessProtocolHandler.StartListenerChannel() GetBlob() contains " + listenerChannelDataLength + " bytes"); listenerChannelContext = ListenerChannelContext.Hydrate(listenerChannelData); this.listenerChannelIdMapping.Add(channelId, listenerChannelContext); Debug.Print("BaseProcessProtocolHandler.StartListenerChannel() listenerChannelContext.ListenerChannelId: " + listenerChannelContext.ListenerChannelId); } } if (this.adphManager == null) { this.adphManager = adphManager; } try { // wether or not a previous AppDomain was running, we're going to start a new one now: Debug.Print("BaseProcessProtocolHandler.StartListenerChannel() calling StartAppDomainProtocolListenerChannel(appKey:" + listenerChannelContext.AppKey + " protocolId:" + protocolId + ")"); adphManager.StartAppDomainProtocolListenerChannel(listenerChannelContext.AppKey, protocolId, listenerChannelCallback); } catch (Exception ex) { if (Fx.IsFatal(ex)) { throw; } if (DiagnosticUtility.ShouldTraceError) { DiagnosticUtility.ExceptionUtility.TraceHandledException(ex, TraceEventType.Error); } HandleStartListenerChannelError(listenerChannelCallback, ex); } } public override void StopProtocol(bool immediate) { Debug.Print("BaseProcessProtocolHandler.StopProtocol(protocolId:" + protocolId + ", immediate:" + immediate + ")"); } public override void StopListenerChannel(int listenerChannelId, bool immediate) { Debug.Print("BaseProcessProtocolHandler.StopListenerChannel(protocolId:" + protocolId + ", listenerChannelId:" + listenerChannelId + ", immediate:" + immediate + ")"); ListenerChannelContext listenerChannelContext = this.listenerChannelIdMapping[listenerChannelId]; adphManager.StopAppDomainProtocolListenerChannel(listenerChannelContext.AppKey, protocolId, listenerChannelId, immediate); lock (this.listenerChannelIdMapping) { // Remove the channel id. this.listenerChannelIdMapping.Remove(listenerChannelId); } } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- FillBehavior.cs
- ClientUrlResolverWrapper.cs
- PackageFilter.cs
- PrimarySelectionAdorner.cs
- MediaElement.cs
- XmlSerializerSection.cs
- WizardStepBase.cs
- Renderer.cs
- NavigationPropertySingletonExpression.cs
- AddressAccessDeniedException.cs
- Helper.cs
- XsltFunctions.cs
- ServicesSection.cs
- ProcessHostServerConfig.cs
- MarshalByValueComponent.cs
- WebPartCloseVerb.cs
- IdentityNotMappedException.cs
- XamlToRtfParser.cs
- StreamGeometry.cs
- UnknownWrapper.cs
- Misc.cs
- EventLogStatus.cs
- BaseDataList.cs
- TextTreeInsertElementUndoUnit.cs
- ProfessionalColors.cs
- FormsAuthenticationModule.cs
- DrawingAttributesDefaultValueFactory.cs
- ExpressionVisitor.cs
- ClientData.cs
- Pts.cs
- thaishape.cs
- QilTypeChecker.cs
- StateChangeEvent.cs
- HttpCachePolicy.cs
- PropertyRef.cs
- SafeRightsManagementPubHandle.cs
- DataQuery.cs
- ProfessionalColors.cs
- IBuiltInEvidence.cs
- StaticResourceExtension.cs
- ClientBuildManagerCallback.cs
- WorkflowPersistenceService.cs
- OleServicesContext.cs
- EffectiveValueEntry.cs
- TreeViewHitTestInfo.cs
- HorizontalAlignConverter.cs
- LineServicesRun.cs
- ActivationService.cs
- CultureInfo.cs
- HttpApplication.cs
- CustomGrammar.cs
- BrushMappingModeValidation.cs
- ModelServiceImpl.cs
- InternalEnumValidator.cs
- ArgumentOutOfRangeException.cs
- ReferenceTypeElement.cs
- TextFormatterImp.cs
- ContentHostHelper.cs
- EntityContainerAssociationSet.cs
- MorphHelpers.cs
- OdbcConnectionFactory.cs
- Module.cs
- OleDbMetaDataFactory.cs
- XPathDescendantIterator.cs
- PtsHost.cs
- FunctionImportMapping.cs
- PresentationSource.cs
- SmiTypedGetterSetter.cs
- Region.cs
- ApplicationSecurityInfo.cs
- ObjectListCommandEventArgs.cs
- CallId.cs
- DependencyObjectPropertyDescriptor.cs
- Scripts.cs
- DbDataReader.cs
- Odbc32.cs
- tibetanshape.cs
- EntitySqlQueryState.cs
- DecimalConverter.cs
- BasicViewGenerator.cs
- XslAstAnalyzer.cs
- ErrorStyle.cs
- ClientOperation.cs
- WriteTimeStream.cs
- ProtocolsSection.cs
- SqlClientWrapperSmiStreamChars.cs
- QueryOperationResponseOfT.cs
- sqlmetadatafactory.cs
- SyntaxCheck.cs
- newinstructionaction.cs
- ParamArrayAttribute.cs
- StaticSiteMapProvider.cs
- ModelItemCollectionImpl.cs
- CompositeCollection.cs
- DropTarget.cs
- WebServiceReceiveDesigner.cs
- LoginStatusDesigner.cs
- HttpProfileBase.cs
- XsdDateTime.cs
- ObjectQueryExecutionPlan.cs