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
- OutputCacheModule.cs
- SimpleWebHandlerParser.cs
- MachineSettingsSection.cs
- MappingModelBuildProvider.cs
- CompiledXpathExpr.cs
- WsatRegistrationHeader.cs
- CompositeCollectionView.cs
- XmlLinkedNode.cs
- ComponentResourceKeyConverter.cs
- Label.cs
- ViewCellRelation.cs
- ZipIOLocalFileBlock.cs
- JavaScriptSerializer.cs
- ProviderConnectionPointCollection.cs
- SqlMetaData.cs
- WebPartDisplayMode.cs
- SchemaNames.cs
- __Filters.cs
- FormatterConverter.cs
- DataGridViewSelectedColumnCollection.cs
- handlecollector.cs
- TableLayoutRowStyleCollection.cs
- AtomServiceDocumentSerializer.cs
- mediaclock.cs
- Margins.cs
- ConfigurationSection.cs
- SafeHandle.cs
- DBCommand.cs
- SecureEnvironment.cs
- AttachedPropertyInfo.cs
- SimpleBitVector32.cs
- ByteStreamGeometryContext.cs
- BinaryObjectInfo.cs
- Error.cs
- WebExceptionStatus.cs
- Operator.cs
- MenuScrollingVisibilityConverter.cs
- VBIdentifierNameEditor.cs
- RemotingConfiguration.cs
- RoutedCommand.cs
- ReverseInheritProperty.cs
- sortedlist.cs
- TextEditorDragDrop.cs
- FormatConvertedBitmap.cs
- EntitySet.cs
- XmlJsonReader.cs
- CatalogPartCollection.cs
- PathSegmentCollection.cs
- ComboBox.cs
- KoreanCalendar.cs
- DataServiceClientException.cs
- SqlClientFactory.cs
- UriTemplateEquivalenceComparer.cs
- TableRow.cs
- DataGridViewCellToolTipTextNeededEventArgs.cs
- RewritingPass.cs
- DynamicHyperLink.cs
- ArrayTypeMismatchException.cs
- FileSystemInfo.cs
- SqlDataSourceCache.cs
- SQLUtility.cs
- DataDocumentXPathNavigator.cs
- SchemaConstraints.cs
- CompModSwitches.cs
- MenuItemStyleCollection.cs
- HttpConfigurationSystem.cs
- PropertyEmitter.cs
- Item.cs
- Frame.cs
- DataRelation.cs
- CheckBoxDesigner.cs
- EntityModelBuildProvider.cs
- AxImporter.cs
- WriterOutput.cs
- TreeIterators.cs
- CacheEntry.cs
- ExtentKey.cs
- LockCookie.cs
- Vector3DValueSerializer.cs
- ToolboxComponentsCreatedEventArgs.cs
- FloaterBaseParagraph.cs
- XPathDocumentBuilder.cs
- AlgoModule.cs
- ToolTip.cs
- IsolatedStorageFile.cs
- _NestedMultipleAsyncResult.cs
- ColorAnimationUsingKeyFrames.cs
- WindowsIdentity.cs
- FollowerQueueCreator.cs
- CookielessData.cs
- RelativeSource.cs
- OutputCacheSection.cs
- GroupQuery.cs
- TransformConverter.cs
- BinaryOperationBinder.cs
- DesignerTransaction.cs
- AlphaSortedEnumConverter.cs
- ToolStripPanelRenderEventArgs.cs
- AttachedAnnotation.cs
- JavaScriptSerializer.cs