LogEntryHeaderv1Deserializer.cs source code in C# .NET

Source code for the .NET framework in C#

                        

Code:

/ WCF / WCF / 3.5.30729.1 / untmp / Orcas / SP / ndp / cdf / src / WCF / TransactionBridge / Microsoft / Transactions / Wsat / Recovery / LogEntryHeaderv1Deserializer.cs / 1 / LogEntryHeaderv1Deserializer.cs

                            //------------------------------------------------------------------------------ 
// Copyright (c) Microsoft Corporation.  All rights reserved.
//-----------------------------------------------------------------------------

// This file contains the class that represents a deserialized log entry 

using System; 
using System.Diagnostics; 
using System.IO;
 
using Microsoft.Transactions.Bridge;
using Microsoft.Transactions.Wsat.InputOutput;
using Microsoft.Transactions.Wsat.Messaging;
 
namespace Microsoft.Transactions.Wsat.Recovery
{ 
    class LogEntryHeaderv1Deserializer : LogEntryHeaderDeserializer 
    {
        Guid localTransactionId; 

        public LogEntryHeaderv1Deserializer(MemoryStream mem, Guid localTransactionId)
            :
            base(mem) 
        {
            this.localTransactionId = localTransactionId; 
        } 

        public override LogEntry DeserializeHeader() 
        {
            // Flags
            LogEntryHeaderv1Flags flags = (LogEntryHeaderv1Flags) SerializationUtils.ReadByte(this.mem);
            if (DebugTrace.Verbose) 
            {
                DebugTrace.Trace(TraceLevel.Verbose, "DeserializeHeader flags: {0}", flags); 
            } 
            CheckFlags(flags);
 
            // Remote transaction id
            string remoteTransactionId;
            if ((flags & LogEntryHeaderv1Flags.StandardRemoteTransactionId) == 0)
            { 
                remoteTransactionId = SerializationUtils.ReadString(mem);
            } 
            else 
            {
                remoteTransactionId = CoordinationContext.CreateNativeIdentifier(this.localTransactionId); 
            }

            // Local enlistmentId
            Guid localEnlistmentId = SerializationUtils.ReadGuid(this.mem); 

            return new LogEntry(remoteTransactionId, this.localTransactionId, localEnlistmentId); 
        } 

        void CheckFlags(LogEntryHeaderv1Flags flags) 
        {
            const LogEntryHeaderv1Flags allFlags = LogEntryHeaderv1Flags.StandardRemoteTransactionId;

            if ((flags | allFlags) != allFlags) 
            {
                // Enum validation-- only one value is accepted. If a different value is 
                // used, we can't trust the data and the safest thing to do is crash. 
                DiagnosticUtility.FailFast("Invalid LogEntryHeaderv1Flags");
            } 
        }
    }
}

// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
// Copyright (c) Microsoft Corporation. All rights reserved.
                        

Link Menu

Network programming in C#, Network Programming in VB.NET, Network Programming in .NET
This book is available now!
Buy at Amazon US or
Buy at Amazon UK