Code:
/ WCF / WCF / 3.5.30729.1 / untmp / Orcas / SP / ndp / cdf / src / WCF / TransactionBridge / Microsoft / Transactions / Wsat / Messaging / Registration.cs / 1 / Registration.cs
//------------------------------------------------------------------------------ // Copyright (c) Microsoft Corporation. All rights reserved. //----------------------------------------------------------------------------- // Define the interfaces and infrastructure needed to receive registration messages using System; using System.ServiceModel.Channels; using System.Diagnostics; using System.ServiceModel; using System.Transactions; using Microsoft.Transactions.Wsat.Protocol; using DiagnosticUtility = Microsoft.Transactions.Bridge.DiagnosticUtility; namespace Microsoft.Transactions.Wsat.Messaging { enum ControlProtocol { None, Completion, Volatile2PC, Durable2PC, } interface IRegistrationCoordinator { void Register (Message message, RequestAsyncResult result); } class RegistrationCoordinatorDispatcher : RequestMessageDispatcher { CoordinationService service; IRegistrationCoordinator dispatch; public RegistrationCoordinatorDispatcher (CoordinationService service, IRegistrationCoordinator dispatch) { this.service = service; this.dispatch = dispatch; } protected override void SendFaultReply (RequestAsyncResult result, Fault fault) { RegistrationProxy.SendFaultResponse (result, fault); } public IAsyncResult BeginRegister(Message message, AsyncCallback callback, object state) { if (DebugTrace.Verbose) { DebugTrace.Trace(TraceLevel.Verbose, "Dispatching Register request"); if (DebugTrace.Pii) DebugTrace.TracePii(TraceLevel.Verbose, "Sender is {0}", CoordinationServiceSecurity.GetSenderName(message)); } RequestAsyncResult result = new RequestAsyncResult(message, callback, state); try { this.dispatch.Register(message, result); } catch (InvalidMessageException e) { DiagnosticUtility.ExceptionUtility.TraceHandledException(e, TraceEventType.Warning); this.OnMessageException(result, message, e, Faults.Version(this.service.ProtocolVersion).InvalidParameters); } catch (CommunicationException e) { DiagnosticUtility.ExceptionUtility.TraceHandledException(e, TraceEventType.Warning); this.OnMessageException(result, message, e, Faults.Version(this.service.ProtocolVersion).RegistrationDispatchFailed); } #pragma warning suppress 56500 // Only catch Exception for InvokeFinalHandler catch (Exception e) { DebugTrace.Trace( TraceLevel.Error, "Unhandled exception {0} dispatching Register message: {1}", e.GetType().Name, e ); // Contractually the dispatch object can only throw CommunicationException. // Our implementation is very careful to only throw this type of exception // (e.g. when deserializing a malformed message body or header...) // Any other exception indicates that things have gone seriously wrong, // so we cannot be trusted to process further messages. This is a QFE-worthy event. DiagnosticUtility.InvokeFinalHandler(e); } return result; } public Message EndRegister(IAsyncResult ar) { RequestAsyncResult result = (RequestAsyncResult) ar; result.End(); return result.Reply; } public static IWSRegistrationCoordinator Instance(CoordinationService service, IRegistrationCoordinator dispatch) { ProtocolVersionHelper.AssertProtocolVersion(service.ProtocolVersion, typeof(RegistrationCoordinatorDispatcher), "V"); //assert valid protocol version switch (service.ProtocolVersion) { case ProtocolVersion.Version10: return new RegistrationCoordinatorDispatcher10(service, dispatch); case ProtocolVersion.Version11: return new RegistrationCoordinatorDispatcher11(service, dispatch); default: return null; // inaccessible path because we have asserted the protocol version } } } [ServiceBehavior( InstanceContextMode = InstanceContextMode.Single, ConcurrencyMode = ConcurrencyMode.Multiple)] class RegistrationCoordinatorDispatcher10 : IWSRegistrationCoordinator10 { RegistrationCoordinatorDispatcher registrationCoordinatorDispatcher; public RegistrationCoordinatorDispatcher10(CoordinationService service, IRegistrationCoordinator dispatch) { ProtocolVersionHelper.AssertProtocolVersion10(service.ProtocolVersion, typeof(RegistrationCoordinatorDispatcher10), "constr"); this.registrationCoordinatorDispatcher = new RegistrationCoordinatorDispatcher(service, dispatch); } public Type ContractType { get { return typeof(IWSRegistrationCoordinator10); } } public IAsyncResult BeginRegister(Message message, AsyncCallback callback, object state) { return this.registrationCoordinatorDispatcher.BeginRegister(message, callback, state); } public Message EndRegister(IAsyncResult ar) { return this.registrationCoordinatorDispatcher.EndRegister(ar); } } [ServiceBehavior( InstanceContextMode = InstanceContextMode.Single, ConcurrencyMode = ConcurrencyMode.Multiple)] class RegistrationCoordinatorDispatcher11 : IWSRegistrationCoordinator11 { RegistrationCoordinatorDispatcher registrationCoordinatorDispatcher; public RegistrationCoordinatorDispatcher11(CoordinationService service, IRegistrationCoordinator dispatch) { ProtocolVersionHelper.AssertProtocolVersion11(service.ProtocolVersion, typeof(RegistrationCoordinatorDispatcher11), "constr"); this.registrationCoordinatorDispatcher = new RegistrationCoordinatorDispatcher(service, dispatch); } public Type ContractType { get { return typeof(IWSRegistrationCoordinator11); } } public IAsyncResult BeginRegister(Message message, AsyncCallback callback, object state) { return this.registrationCoordinatorDispatcher.BeginRegister(message, callback, state); } public Message EndRegister(IAsyncResult ar) { return this.registrationCoordinatorDispatcher.EndRegister(ar); } } } // 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
- InstancePersistenceCommandException.cs
- ProxyHelper.cs
- Pen.cs
- TreeViewDataItemAutomationPeer.cs
- StringAnimationUsingKeyFrames.cs
- PeerPresenceInfo.cs
- ResourceProperty.cs
- CharAnimationBase.cs
- HitTestResult.cs
- CreateBookmarkScope.cs
- Cell.cs
- DoubleCollectionConverter.cs
- Pool.cs
- MergeLocalizationDirectives.cs
- XXXOnTypeBuilderInstantiation.cs
- TextStore.cs
- SystemIPInterfaceStatistics.cs
- RemotingException.cs
- PropertyToken.cs
- TargetControlTypeCache.cs
- ActivityInfo.cs
- RootBrowserWindowAutomationPeer.cs
- OpenTypeLayout.cs
- DrawListViewItemEventArgs.cs
- ToolBar.cs
- Int32Collection.cs
- ButtonFieldBase.cs
- CornerRadiusConverter.cs
- ReadOnlyDataSourceView.cs
- BaseCAMarshaler.cs
- BrowserCapabilitiesFactory35.cs
- StickyNote.cs
- VectorValueSerializer.cs
- MatrixTransform.cs
- XmlSchemaIdentityConstraint.cs
- IsolatedStorageFileStream.cs
- AdornerHitTestResult.cs
- SiteMapProvider.cs
- ParameterRefs.cs
- Internal.cs
- XmlSchemaFacet.cs
- CellRelation.cs
- DbMetaDataFactory.cs
- BookmarkEventArgs.cs
- followingsibling.cs
- OleDbConnection.cs
- LineInfo.cs
- BulletedListEventArgs.cs
- MeasureItemEvent.cs
- ListSortDescriptionCollection.cs
- WpfWebRequestHelper.cs
- EditorBrowsableAttribute.cs
- RegistryKey.cs
- CellCreator.cs
- OletxResourceManager.cs
- ListCollectionView.cs
- PolyBezierSegmentFigureLogic.cs
- ColorTranslator.cs
- ProcessRequestArgs.cs
- EntityDescriptor.cs
- PreloadedPackages.cs
- AnnotationElement.cs
- Animatable.cs
- ExtendedPropertiesHandler.cs
- ObjectViewListener.cs
- DesignBindingValueUIHandler.cs
- XmlAttributeProperties.cs
- BackStopAuthenticationModule.cs
- DataGridCellItemAutomationPeer.cs
- EditorZone.cs
- RetrieveVirtualItemEventArgs.cs
- ClientCultureInfo.cs
- XPathParser.cs
- ScrollBar.cs
- StagingAreaInputItem.cs
- MemberRelationshipService.cs
- EdmSchemaAttribute.cs
- X509Certificate2Collection.cs
- SafeNativeMethods.cs
- SessionParameter.cs
- PropertyCondition.cs
- AccessibleObject.cs
- TextParaLineResult.cs
- SecurityRuntime.cs
- ContextMenu.cs
- CharacterBuffer.cs
- FormViewDeleteEventArgs.cs
- panel.cs
- CurrentTimeZone.cs
- Cursor.cs
- OperationResponse.cs
- ItemAutomationPeer.cs
- TypeName.cs
- XsltOutput.cs
- LockedAssemblyCache.cs
- DataPagerFieldCommandEventArgs.cs
- DataServiceProviderMethods.cs
- SchemaCollectionCompiler.cs
- CookieParameter.cs
- SeparatorAutomationPeer.cs