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
- ItemContainerProviderWrapper.cs
- XmlAttributeCollection.cs
- AccessibleObject.cs
- DependencyProperty.cs
- ImageMapEventArgs.cs
- SecurityPolicySection.cs
- Matrix.cs
- ConnectionPoint.cs
- CroppedBitmap.cs
- WindowProviderWrapper.cs
- SettingsBindableAttribute.cs
- Normalization.cs
- OrderedDictionary.cs
- DropShadowBitmapEffect.cs
- MessageSecurityOverHttp.cs
- DictionarySectionHandler.cs
- TextRunCacheImp.cs
- GridViewCommandEventArgs.cs
- ProtocolElement.cs
- MsmqInputChannelBase.cs
- SqlSelectClauseBuilder.cs
- XmlResolver.cs
- SmtpReplyReaderFactory.cs
- FreezableOperations.cs
- SerializationSectionGroup.cs
- Evidence.cs
- ContextQuery.cs
- LogEntryUtils.cs
- BindingExpression.cs
- CopyNamespacesAction.cs
- SiteMapPath.cs
- BindingsCollection.cs
- RuntimeConfig.cs
- GridProviderWrapper.cs
- VectorCollectionConverter.cs
- PageWrapper.cs
- UIElement3D.cs
- WriteableOnDemandStream.cs
- CaseInsensitiveHashCodeProvider.cs
- DefaultTextStoreTextComposition.cs
- UpdateManifestForBrowserApplication.cs
- MgmtConfigurationRecord.cs
- Component.cs
- SqlGenerator.cs
- TextMessageEncodingBindingElement.cs
- TemplateXamlTreeBuilder.cs
- StickyNoteAnnotations.cs
- ColorKeyFrameCollection.cs
- SafeRightsManagementPubHandle.cs
- WsatServiceCertificate.cs
- LoadWorkflowCommand.cs
- SqlWriter.cs
- MessageLoggingElement.cs
- CodeTypeParameterCollection.cs
- DashStyles.cs
- MbpInfo.cs
- RSAPKCS1SignatureDeformatter.cs
- HighlightComponent.cs
- SerializationEventsCache.cs
- ApplicationInterop.cs
- SeparatorAutomationPeer.cs
- ManagementDateTime.cs
- Int32RectConverter.cs
- RandomNumberGenerator.cs
- CodeDOMUtility.cs
- WmlPageAdapter.cs
- HitTestParameters.cs
- login.cs
- GeometryDrawing.cs
- KnownIds.cs
- CodeCatchClause.cs
- Matrix3DStack.cs
- SeparatorAutomationPeer.cs
- TrackBarRenderer.cs
- AdornerHitTestResult.cs
- WebPartDisplayModeCollection.cs
- ValidationException.cs
- HyperLink.cs
- PresentationSource.cs
- TypeElement.cs
- WebEvents.cs
- NameService.cs
- RuntimeWrappedException.cs
- UnsafeNativeMethods.cs
- GuidConverter.cs
- Transform.cs
- RefreshPropertiesAttribute.cs
- UpdateCommand.cs
- InputScopeNameConverter.cs
- Rotation3DAnimationBase.cs
- SchemaTableColumn.cs
- ProcessProtocolHandler.cs
- Nullable.cs
- ReplacementText.cs
- ReachFixedDocumentSerializer.cs
- AuthenticateEventArgs.cs
- IfAction.cs
- NameValueCache.cs
- TextServicesDisplayAttributePropertyRanges.cs
- Pen.cs