private WsatRegistrationHeader ReadRegistrationHeader(Message message)
        {
            WsatRegistrationHeader header = null;

            try
            {
                header = WsatRegistrationHeader.ReadFrom(message);
            }
            catch (InvalidEnlistmentHeaderException exception)
            {
                DiagnosticUtility.ExceptionUtility.TraceHandledException(exception, TraceEventType.Error);
                if (DebugTrace.Error)
                {
                    DebugTrace.Trace(TraceLevel.Error, "Invalid RegisterInfo header found in register message: {0}", exception.Message);
                }
            }
            return(header);
        }
        public void Register(Message message, Microsoft.Transactions.Wsat.Messaging.RequestAsyncResult result)
        {
            Microsoft.Transactions.Wsat.Messaging.Register register = new Microsoft.Transactions.Wsat.Messaging.Register(message, this.state.ProtocolVersion);
            EndpointAddress        participantProtocolService       = register.ParticipantProtocolService;
            WsatRegistrationHeader header = WsatRegistrationHeader.ReadFrom(message);

            if (header == null)
            {
                if (DebugTrace.Warning)
                {
                    DebugTrace.Trace(TraceLevel.Warning, "Rejecting Register message with no registration header");
                }
                this.SendFault(result, this.state.Faults.InvalidParameters);
                return;
            }
            switch (register.Protocol)
            {
            case ControlProtocol.Completion:
            {
                CompletionEnlistment completion = this.state.Lookup.FindEnlistment(header.TransactionId) as CompletionEnlistment;
                if (completion != null)
                {
                    CompletionParticipantProxy proxy = this.state.TryCreateCompletionParticipantProxy(participantProtocolService);
                    if (proxy == null)
                    {
                        if (DebugTrace.Warning)
                        {
                            DebugTrace.Trace(TraceLevel.Warning, "Rejecting Register message for completion on no completion enlistment");
                        }
                        this.SendFault(result, this.state.Faults.InvalidParameters);
                        return;
                    }
                    try
                    {
                        completion.StateMachine.Enqueue(new MsgRegisterCompletionEvent(completion, ref register, result, proxy));
                        return;
                    }
                    finally
                    {
                        proxy.Release();
                    }
                    break;
                }
                if (DebugTrace.Warning)
                {
                    DebugTrace.Trace(TraceLevel.Warning, "Rejecting uncorrelated Register message for completion");
                }
                this.SendFault(result, this.state.Faults.UnknownCompletionEnlistment);
                return;
            }

            case ControlProtocol.Volatile2PC:
            case ControlProtocol.Durable2PC:
                break;

            default:
                goto Label_0222;
            }
            if (!this.state.TransactionManager.Settings.NetworkOutboundAccess)
            {
                if (DebugTrace.Warning)
                {
                    DebugTrace.Trace(TraceLevel.Warning, "Rejecting Register message because outbound transactions are disabled");
                }
                this.SendFault(result, this.state.Faults.ParticipantRegistrationNetAccessDisabled);
                return;
            }
            if (register.Loopback == this.state.ProcessId)
            {
                if (DebugTrace.Warning)
                {
                    DebugTrace.Trace(TraceLevel.Warning, "Rejecting recursive Register message from self");
                }
                this.SendFault(result, this.state.Faults.ParticipantRegistrationLoopback);
                return;
            }
            TwoPhaseCommitParticipantProxy proxy2 = this.state.TryCreateTwoPhaseCommitParticipantProxy(participantProtocolService);

            if (proxy2 == null)
            {
                if (DebugTrace.Warning)
                {
                    DebugTrace.Trace(TraceLevel.Warning, "Rejecting Register message because 2PC proxy could not be created");
                }
                this.SendFault(result, this.state.Faults.InvalidParameters);
                return;
            }
            try
            {
                ParticipantEnlistment participant = new ParticipantEnlistment(this.state, header, register.Protocol, proxy2);
                this.state.TransactionManagerSend.Register(participant, new MsgRegisterEvent(participant, ref register, result));
                return;
            }
            finally
            {
                proxy2.Release();
            }
Label_0222:
            Microsoft.Transactions.Bridge.DiagnosticUtility.FailFast("Registration protocol should have been validated");
        }