Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / cdf / src / NetFx35 / System.WorkflowServices / System / ServiceModel / Dispatcher / DurableMessageDispatchInspector.cs / 1305376 / DurableMessageDispatchInspector.cs
//------------------------------------------------------------ // Copyright (c) Microsoft Corporation. All rights reserved. //----------------------------------------------------------- namespace System.ServiceModel.Dispatcher { using System.ServiceModel.Channels; class DurableMessageDispatchInspector : IDispatchMessageInspector { public const string NewDurableInstanceIdPropertyName = "newDurableInstanceIdProperty"; const string suppressContextOnReply = "suppressContextOnReply"; SessionMode sessionMode; public DurableMessageDispatchInspector(SessionMode sessionMode) { this.sessionMode = sessionMode; } public static void SuppressContextOnReply(OperationContext operationContext) { if (operationContext == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("operationContext"); } operationContext.OutgoingMessageProperties[suppressContextOnReply] = true; } public object AfterReceiveRequest(ref Message request, IClientChannel channel, InstanceContext instanceContext) { if (instanceContext == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("instanceContext"); } if (request == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("request"); } if (sessionMode != SessionMode.NotAllowed) { object result = null; if (request.Properties.TryGetValue(NewDurableInstanceIdPropertyName, out result)) { return result.ToString(); } } return null; } public void BeforeSendReply(ref Message reply, object correlationState) { try { if (reply != null) { ContextMessageProperty context = null; if (sessionMode == SessionMode.NotAllowed || reply.Properties.ContainsKey(suppressContextOnReply)) { if (ContextMessageProperty.TryGet(reply, out context)) { context.Context.Clear(); } } else { string newInstanceId = correlationState as string; if (newInstanceId != null) { if (!ContextMessageProperty.TryGet(reply, out context)) { context = new ContextMessageProperty(); context.Context[WellKnownContextProperties.InstanceId] = newInstanceId; context.AddOrReplaceInMessage(reply); } else { context.Context[WellKnownContextProperties.InstanceId] = newInstanceId; } } } } } finally { DurableInstance durableInstance = OperationContext.Current.InstanceContext.Extensions.Find(); if (durableInstance == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError( new InvalidOperationException( SR2.GetString( SR2.RequiredInstanceContextExtensionNotFound, typeof(DurableInstance).Name))); } //Decrement InstanceActivity Count durableInstance.DecrementActivityCount(); } } } } // 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
- ContainsRowNumberChecker.cs
- TraceHandlerErrorFormatter.cs
- TaskScheduler.cs
- StyleModeStack.cs
- HttpListenerResponse.cs
- PropertyEntry.cs
- PathData.cs
- ZipIOCentralDirectoryFileHeader.cs
- ConfigurationPropertyAttribute.cs
- QilName.cs
- CutCopyPasteHelper.cs
- AssemblyBuilder.cs
- ExpressionCopier.cs
- XLinq.cs
- MethodCallTranslator.cs
- SamlConstants.cs
- ExtensionQuery.cs
- ObjectListComponentEditor.cs
- SystemResourceHost.cs
- QueryPageSettingsEventArgs.cs
- RtfNavigator.cs
- JournalNavigationScope.cs
- Stack.cs
- GridViewSortEventArgs.cs
- TextElementCollectionHelper.cs
- TypeSystem.cs
- TemplateControlCodeDomTreeGenerator.cs
- Model3DCollection.cs
- ProfileSection.cs
- ExpressionEditorAttribute.cs
- XamlUtilities.cs
- MatrixIndependentAnimationStorage.cs
- DataGridViewRowErrorTextNeededEventArgs.cs
- PtsPage.cs
- DataErrorValidationRule.cs
- SamlNameIdentifierClaimResource.cs
- URL.cs
- SettingsPropertyWrongTypeException.cs
- SafeRegistryHandle.cs
- HttpCachePolicyWrapper.cs
- DataDesignUtil.cs
- SqlInfoMessageEvent.cs
- DbgUtil.cs
- CodeTypeReference.cs
- DataGridViewCellLinkedList.cs
- Opcode.cs
- Point3DAnimationBase.cs
- XPathLexer.cs
- ListViewHitTestInfo.cs
- WebPartsPersonalizationAuthorization.cs
- SafeNativeMethods.cs
- ComponentManagerBroker.cs
- InternalConfigRoot.cs
- Rotation3DAnimationBase.cs
- SmtpCommands.cs
- TransformProviderWrapper.cs
- SelectorAutomationPeer.cs
- _LoggingObject.cs
- BamlTreeNode.cs
- DBDataPermissionAttribute.cs
- ContainerVisual.cs
- MultipartIdentifier.cs
- FontFamily.cs
- ConfigXmlWhitespace.cs
- EventBuilder.cs
- AssemblyNameProxy.cs
- PackageProperties.cs
- NullableDecimalMinMaxAggregationOperator.cs
- SharedStatics.cs
- TimeSpanFormat.cs
- XmlImplementation.cs
- FontStyle.cs
- PolyBezierSegment.cs
- KeyedCollection.cs
- OutputCacheSection.cs
- AttachedPropertyBrowsableAttribute.cs
- LocationSectionRecord.cs
- ExtenderProvidedPropertyAttribute.cs
- StringHandle.cs
- M3DUtil.cs
- KnownTypeAttribute.cs
- DistributedTransactionPermission.cs
- Vars.cs
- TimeSpan.cs
- GacUtil.cs
- SiteMapPath.cs
- HelloMessageApril2005.cs
- WhiteSpaceTrimStringConverter.cs
- DesignerAttribute.cs
- File.cs
- QilStrConcatenator.cs
- UriWriter.cs
- AdRotatorDesigner.cs
- Base64Encoding.cs
- SID.cs
- ConfigurationLocationCollection.cs
- SerialReceived.cs
- DataPagerFieldCommandEventArgs.cs
- SystemFonts.cs
- WmiInstallComponent.cs