예제 #1
0
 private byte[] SerializeLogEntry(LogEntry logEntry)
 {
     byte[] buffer = new WsATv1LogEntrySerializer(logEntry, this.protocolVersion).Serialize();
     if (DebugTrace.Verbose)
     {
         DebugTrace.Trace(TraceLevel.Verbose, "Serialized {0} byte buffer", buffer.Length);
     }
     if (buffer.Length > this.maxLogEntrySize)
     {
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new SerializationException(Microsoft.Transactions.SR.GetString("SerializationLogEntryTooBig", new object[] { buffer.Length })));
     }
     return(buffer);
 }
        protected override void DeserializeExtended()
        {
            DebugTrace.TraceEnter(this, "DeserializeExtended");
            WsATv1LogEntryVersion version = (WsATv1LogEntryVersion)SerializationUtils.ReadByte(base.mem);

            if (!Enum.IsDefined(typeof(WsATv1LogEntryVersion), version))
            {
                Microsoft.Transactions.Bridge.DiagnosticUtility.FailFast("Unsupported WsATv1LogEntryVersion");
            }
            WsATv1LogEntryFlags flags = (WsATv1LogEntryFlags)SerializationUtils.ReadByte(base.mem);

            if (DebugTrace.Verbose)
            {
                DebugTrace.Trace(TraceLevel.Verbose, "DeserializeExtended flags: {0}", flags);
            }
            this.CheckFlags(flags);
            if (((byte)(flags & WsATv1LogEntryFlags.OptimizedEndpointRepresentation)) == 0)
            {
                base.entry.Endpoint = SerializationUtils.ReadEndpointAddress(base.mem, this.protocolVersion);
                if (DebugTrace.Verbose)
                {
                    DebugTrace.Trace(TraceLevel.Verbose, "Read endpoint address: {0}", base.entry.Endpoint.Uri);
                }
            }
            else
            {
                int    num;
                string str2;
                Guid   guid = SerializationUtils.ReadGuid(base.mem);
                if (DebugTrace.Verbose)
                {
                    DebugTrace.Trace(TraceLevel.Verbose, "Read remote EnlistmentId: {0}", guid);
                }
                string str = SerializationUtils.ReadString(base.mem);
                if (DebugTrace.Verbose)
                {
                    DebugTrace.Trace(TraceLevel.Verbose, "Read hostName: {0}", str);
                }
                if (((byte)(flags & WsATv1LogEntryFlags.UsesDefaultPort)) != 0)
                {
                    num = 0x944;
                }
                else
                {
                    num = SerializationUtils.ReadInt(base.mem);
                    if (DebugTrace.Verbose)
                    {
                        DebugTrace.Trace(TraceLevel.Verbose, "Read port: {0}", num);
                    }
                }
                if (((byte)(flags & WsATv1LogEntryFlags.UsesStandardCoordinatorAddressPath)) != 0)
                {
                    str2 = WsATv1LogEntrySerializer.StandardCoordinatorAddressPath(this.protocolVersion);
                }
                else if (((byte)(flags & WsATv1LogEntryFlags.UsesStandardParticipantAddressPath)) != 0)
                {
                    str2 = WsATv1LogEntrySerializer.StandardParticipantAddressPath(this.protocolVersion);
                }
                else
                {
                    str2 = SerializationUtils.ReadString(base.mem);
                    if (DebugTrace.Verbose)
                    {
                        DebugTrace.Trace(TraceLevel.Verbose, "Read address path: {0}", str2);
                    }
                }
                UriBuilder       builder = new UriBuilder(Uri.UriSchemeHttps, str, num, str2);
                EnlistmentHeader header  = new EnlistmentHeader(guid, ControlProtocol.Durable2PC);
                base.entry.Endpoint = new EndpointAddress(builder.Uri, new AddressHeader[] { header });
            }
            DebugTrace.TraceLeave(this, "DeserializeExtended");
        }