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
- Int32.cs
- Journaling.cs
- BoundsDrawingContextWalker.cs
- SqlBulkCopy.cs
- securitycriticaldataformultiplegetandset.cs
- DesignConnectionCollection.cs
- EntityDesignerUtils.cs
- ReceiveMessageAndVerifySecurityAsyncResultBase.cs
- XamlFigureLengthSerializer.cs
- StringBuilder.cs
- DataGridViewRowsAddedEventArgs.cs
- SqlError.cs
- HtmlImage.cs
- sqlcontext.cs
- WorkflowInlining.cs
- CodeMethodInvokeExpression.cs
- TraceHwndHost.cs
- SHA512Managed.cs
- XmlChoiceIdentifierAttribute.cs
- SByte.cs
- ClientRoleProvider.cs
- listitem.cs
- DockPanel.cs
- HttpListenerPrefixCollection.cs
- GeneralTransform.cs
- DescendantOverDescendantQuery.cs
- DesignTimeTemplateParser.cs
- DataSourceSelectArguments.cs
- MatrixCamera.cs
- SecurityTokenValidationException.cs
- TakeOrSkipWhileQueryOperator.cs
- JavaScriptObjectDeserializer.cs
- ColumnPropertiesGroup.cs
- SystemColors.cs
- ToolboxItemAttribute.cs
- AspNetHostingPermission.cs
- LabelAutomationPeer.cs
- BinaryParser.cs
- Tuple.cs
- ModelUIElement3D.cs
- SerialErrors.cs
- Point3D.cs
- Sorting.cs
- LiteralText.cs
- Matrix3DStack.cs
- PeerToPeerException.cs
- ToolStripProfessionalLowResolutionRenderer.cs
- TraceUtility.cs
- DBSqlParserTable.cs
- MemberProjectionIndex.cs
- FindRequestContext.cs
- ForwardPositionQuery.cs
- SecurityUniqueId.cs
- SamlAuthenticationClaimResource.cs
- PropertyGridEditorPart.cs
- MutexSecurity.cs
- IsolatedStorageFile.cs
- CharEnumerator.cs
- MediaPlayer.cs
- EncoderExceptionFallback.cs
- PositiveTimeSpanValidator.cs
- DataGridViewAutoSizeColumnsModeEventArgs.cs
- StylusOverProperty.cs
- FixedLineResult.cs
- LayoutEngine.cs
- UIElement3D.cs
- dtdvalidator.cs
- CodeAttributeDeclaration.cs
- WMIGenerator.cs
- EdmPropertyAttribute.cs
- X509CertificateValidationMode.cs
- ImageFormat.cs
- AttributeExtensions.cs
- _Connection.cs
- ObjectStateFormatter.cs
- MessageHeaderInfoTraceRecord.cs
- MimeObjectFactory.cs
- XPathAncestorIterator.cs
- EnumerableRowCollectionExtensions.cs
- Collection.cs
- Misc.cs
- IERequestCache.cs
- Adorner.cs
- RecordsAffectedEventArgs.cs
- AuthenticationModulesSection.cs
- Int16Animation.cs
- SchemaEntity.cs
- RoutedEventArgs.cs
- ProfileModule.cs
- ToolStripSplitStackLayout.cs
- WorkflowOwnerAsyncResult.cs
- WinEventQueueItem.cs
- XmlTextWriter.cs
- DefaultAsyncDataDispatcher.cs
- TextBoxRenderer.cs
- DataGridViewIntLinkedList.cs
- ThreadAttributes.cs
- DataRelationPropertyDescriptor.cs
- PaintEvent.cs
- TargetException.cs