LogEntryHeaderSerializer.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 / LogEntryHeaderSerializer.cs / 1 / LogEntryHeaderSerializer.cs

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

// This file contains the knowledge of how to serialize a log entry header 
// in the current format
 
using System; 
using System.IO;
 
using Microsoft.Transactions.Wsat.InputOutput;
using Microsoft.Transactions.Wsat.Messaging;

namespace Microsoft.Transactions.Wsat.Recovery 
{
    enum LogEntryHeaderVersion : byte 
    { 
        v1 = 1,
    } 

    [Flags]
    enum LogEntryHeaderv1Flags : byte
    { 
        StandardRemoteTransactionId = 0x01,
    } 
 
    class LogEntryHeaderSerializer
    { 
        LogEntry logEntry;

        public LogEntryHeaderSerializer(LogEntry logEntry)
        { 
            this.logEntry = logEntry;
        } 
 
        public MemoryStream WriteHeader()
        { 
            MemoryStream mem = new MemoryStream();

            // Versions
            mem.WriteByte((byte) LogEntryHeaderVersion.v1); 

            // Flags and remote transaction Id 
            if (CoordinationContext.IsNativeIdentifier(logEntry.RemoteTransactionId, 
                                                       logEntry.LocalTransactionId))
            { 
                mem.WriteByte((byte) LogEntryHeaderv1Flags.StandardRemoteTransactionId);
            }
            else
            { 
                mem.WriteByte(0);
                SerializationUtils.WriteString(mem, logEntry.RemoteTransactionId); 
            } 

            // Local enlistmentId 
            Guid localEnlistmentId = logEntry.LocalEnlistmentId;
            SerializationUtils.WriteGuid(mem, ref localEnlistmentId);

            return mem; 
        }
    } 
} 

// 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