Code:
/ WCF / WCF / 3.5.30729.1 / untmp / Orcas / SP / ndp / cdf / src / WCF / TransactionBridge / Microsoft / Transactions / Wsat / Recovery / DotNetATv1WindowsLogEntryDeserializer.cs / 1 / DotNetATv1WindowsLogEntryDeserializer.cs
//------------------------------------------------------------------------------ // Copyright (c) Microsoft Corporation. All rights reserved. //----------------------------------------------------------------------------- // This file contains the knowledge of how to serialize a .NET-AT v1 Windows log entry using System; using System.ServiceModel; using System.Diagnostics; using System.IO; using Microsoft.Transactions.Bridge; using Microsoft.Transactions.Wsat.Messaging; using Microsoft.Transactions.Wsat.Protocol; using DiagnosticUtility = Microsoft.Transactions.Bridge.DiagnosticUtility; namespace Microsoft.Transactions.Wsat.Recovery { class WsATv1LogEntryDeserializer : LogEntryDeserializer { // ProtocolVersion protocolVersion; public WsATv1LogEntryDeserializer(MemoryStream mem, LogEntry entry, ProtocolVersion protocolVersion) : base(mem, entry) { this.protocolVersion = protocolVersion; } protected override void DeserializeExtended() { DebugTrace.TraceEnter(this, "DeserializeExtended"); // Version WsATv1LogEntryVersion version = (WsATv1LogEntryVersion) SerializationUtils.ReadByte(mem); if (!Enum.IsDefined(typeof(WsATv1LogEntryVersion), version)) { // The deserializer only supports two versions of log entry. It // cannot make sense of other versions and must failfast if logging // was done incorrectly. The assumption is that no one else writes to the // log. If someone else DOES write to the log, we can't deal with it and // continue on, so failure is the safest option. DiagnosticUtility.FailFast("Unsupported WsATv1LogEntryVersion"); } // Flags WsATv1LogEntryFlags flags = (WsATv1LogEntryFlags) SerializationUtils.ReadByte(mem); if (DebugTrace.Verbose) { DebugTrace.Trace(TraceLevel.Verbose, "DeserializeExtended flags: {0}", flags); } CheckFlags(flags); // Check for optimized EPR if ((flags & WsATv1LogEntryFlags.OptimizedEndpointRepresentation) == 0) { this.entry.Endpoint = SerializationUtils.ReadEndpointAddress(this.mem, this.protocolVersion); if (DebugTrace.Verbose) { DebugTrace.Trace(TraceLevel.Verbose, "Read endpoint address: {0}", this.entry.Endpoint.Uri); } } else { // Remote enlistmentId Guid remoteEnlistmentId = SerializationUtils.ReadGuid(this.mem); if (DebugTrace.Verbose) { DebugTrace.Trace(TraceLevel.Verbose, "Read remote EnlistmentId: {0}", remoteEnlistmentId); } // HostName string hostName = SerializationUtils.ReadString(this.mem); if (DebugTrace.Verbose) { DebugTrace.Trace(TraceLevel.Verbose, "Read hostName: {0}", hostName); } // Port int port; if ((flags & WsATv1LogEntryFlags.UsesDefaultPort) != 0) { port = Configuration.DefaultHttpsPort; } else { port = SerializationUtils.ReadInt(mem); if (DebugTrace.Verbose) { DebugTrace.Trace(TraceLevel.Verbose, "Read port: {0}", port); } } // Address path string addressPath; if ((flags & WsATv1LogEntryFlags.UsesStandardCoordinatorAddressPath) != 0) { addressPath = WsATv1LogEntrySerializer.StandardCoordinatorAddressPath(this.protocolVersion); } else if ((flags & WsATv1LogEntryFlags.UsesStandardParticipantAddressPath) != 0) { addressPath = WsATv1LogEntrySerializer.StandardParticipantAddressPath(this.protocolVersion); } else { addressPath = SerializationUtils.ReadString(this.mem); if (DebugTrace.Verbose) { DebugTrace.Trace(TraceLevel.Verbose, "Read address path: {0}", addressPath); } } // // Create address from deserialized parts // UriBuilder uriBuilder = new UriBuilder(Uri.UriSchemeHttps, hostName, port, addressPath); // Create EndpointAddress from deserialized parts EnlistmentHeader refParam = new EnlistmentHeader(remoteEnlistmentId, ControlProtocol.Durable2PC); this.entry.Endpoint = new EndpointAddress(uriBuilder.Uri, refParam); } DebugTrace.TraceLeave(this, "DeserializeExtended"); } void CheckFlags(WsATv1LogEntryFlags flags) { // Detect invalid flags const WsATv1LogEntryFlags allFlags = WsATv1LogEntryFlags.OptimizedEndpointRepresentation | WsATv1LogEntryFlags.UsesDefaultPort | WsATv1LogEntryFlags.UsesStandardCoordinatorAddressPath | WsATv1LogEntryFlags.UsesStandardParticipantAddressPath; if ((flags | allFlags) != allFlags) { // An invalid Enum value on this internal code path indicates // a product bug and violates assumptions about // valid values in MSDTC. DiagnosticUtility.FailFast("Invalid WsATv1LogEntryFlags"); } // If OptimizedEndpointRepresentation is not set, no other flag should be set if ((flags & WsATv1LogEntryFlags.OptimizedEndpointRepresentation) == 0 && flags != 0) { // The deserializer only supports one version of log entry. It cannot // make sense of other versions and must failfast if logging was done // incorrectly. The assumption is that noone else writes to the log. // If someone else DOES write to the log, we can't deal with it and // continue on, so failure is the safest option. DiagnosticUtility.FailFast("If OptimizedEndpointRepresentation is not set, " + "no other flag should be set"); } // Both address flags cannot be set const WsATv1LogEntryFlags allAddressFlags = WsATv1LogEntryFlags.UsesStandardCoordinatorAddressPath | WsATv1LogEntryFlags.UsesStandardParticipantAddressPath; if ((flags & allAddressFlags) == allAddressFlags) { // An invalid Enum value on this internal code path indicates // a product bug and violates assumptions about // valid values in MSDTC. DiagnosticUtility.FailFast("Both address flags cannot be set at once"); } } } } // 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
- TextTreeRootNode.cs
- PathGradientBrush.cs
- KnownBoxes.cs
- ValidatedControlConverter.cs
- SystemIPAddressInformation.cs
- MessageHeader.cs
- SystemResourceKey.cs
- XmlDataSourceView.cs
- ProtocolsConfiguration.cs
- TextSearch.cs
- TdsParserSafeHandles.cs
- _FtpControlStream.cs
- TableLayoutSettings.cs
- ManageRequest.cs
- PreloadedPackages.cs
- WebPartVerbCollection.cs
- FontUnitConverter.cs
- ToolStripPanelRenderEventArgs.cs
- TypeContext.cs
- ExpressionEditorSheet.cs
- SmtpFailedRecipientException.cs
- LongPath.cs
- HostingEnvironmentWrapper.cs
- StylusPointPropertyInfo.cs
- SqlComparer.cs
- BuildProvider.cs
- ProcessStartInfo.cs
- ParameterModifier.cs
- MemberAssignment.cs
- SQLDouble.cs
- EmptyEnumerator.cs
- AvTrace.cs
- ComponentConverter.cs
- HybridDictionary.cs
- FragmentNavigationEventArgs.cs
- KeyedCollection.cs
- MailDefinition.cs
- CorrelationHandle.cs
- Stroke2.cs
- ObjectHandle.cs
- SqlRowUpdatingEvent.cs
- SafeRightsManagementEnvironmentHandle.cs
- Point4DValueSerializer.cs
- AssemblyAttributes.cs
- KeyboardDevice.cs
- InheritanceContextChangedEventManager.cs
- SimplePropertyEntry.cs
- PopOutPanel.cs
- ThicknessAnimationUsingKeyFrames.cs
- UInt16Storage.cs
- ServerValidateEventArgs.cs
- MatrixKeyFrameCollection.cs
- TdsParserHelperClasses.cs
- WebPartActionVerb.cs
- CustomExpressionEventArgs.cs
- XmlSchemaValidator.cs
- QueryUtil.cs
- datacache.cs
- AssemblyFilter.cs
- XmlSchemaIdentityConstraint.cs
- SevenBitStream.cs
- System.Data_BID.cs
- CoTaskMemUnicodeSafeHandle.cs
- DocumentXmlWriter.cs
- JavaScriptSerializer.cs
- TripleDESCryptoServiceProvider.cs
- ImageEditor.cs
- FixedStringLookup.cs
- EventTask.cs
- CompiledRegexRunner.cs
- RectangleHotSpot.cs
- SimpleRecyclingCache.cs
- ParseHttpDate.cs
- BrushMappingModeValidation.cs
- DeferrableContent.cs
- ProxyElement.cs
- NativeCppClassAttribute.cs
- SecurityHelper.cs
- GeneralTransform3DGroup.cs
- MailMessageEventArgs.cs
- EventSinkHelperWriter.cs
- FixedPosition.cs
- TouchFrameEventArgs.cs
- TextTreeDeleteContentUndoUnit.cs
- SetIterators.cs
- TypedElement.cs
- formatter.cs
- BaseParagraph.cs
- DynamicExpression.cs
- DocumentViewer.cs
- SkewTransform.cs
- WindowsListBox.cs
- XmlNode.cs
- PassportAuthenticationModule.cs
- LogLogRecordHeader.cs
- CharConverter.cs
- WindowsFormsHelpers.cs
- HttpResponseWrapper.cs
- ConstraintConverter.cs
- StreamGeometry.cs