public MsgRegisterCompletionEvent(CompletionEnlistment completion, ref Register register, RequestAsyncResult result, CompletionParticipantProxy proxy) : base(completion)
 {
     this.register = register;
     proxy.AddRef();
     this.proxy = proxy;
     this.result = result;
 }
 private RegisterMessage CreateRegisterMessage(ref Register register)
 {
     RegisterMessage message = new RegisterMessage(base.messageVersion, ref register);
     if (register.SupportingToken != null)
     {
         CoordinationServiceSecurity.AddSupportingToken(message, register.SupportingToken);
     }
     return message;
 }
 public IAsyncResult BeginSendRegister(ref Register register, AsyncCallback callback, object state)
 {
     if (DebugTrace.Verbose)
     {
         DebugTrace.Trace(TraceLevel.Verbose, "Sending Register to {0}", base.to.Uri);
     }
     Message message = this.CreateRegisterMessage(ref register);
     return base.BeginSendRequest(message, callback, state);
 }
 public RegisterResponse SendRegister(ref Register register)
 {
     if (DebugTrace.Verbose)
     {
         DebugTrace.Trace(TraceLevel.Verbose, "Sending Register to {0}", base.to.Uri);
     }
     Message message = this.CreateRegisterMessage(ref register);
     Message message2 = base.SendRequest(message, base.coordinationStrings.RegisterResponseAction);
     using (message2)
     {
         if (DebugTrace.Verbose)
         {
             DebugTrace.Trace(TraceLevel.Verbose, "Dispatching RegisterResponse reply");
             if (DebugTrace.Pii)
             {
                 DebugTrace.TracePii(TraceLevel.Verbose, "Sender is {0}", CoordinationServiceSecurity.GetSenderName(message2));
             }
         }
         return new RegisterResponse(message2, base.protocolVersion);
     }
 }
 public MsgRegisterEvent(ParticipantEnlistment participant, ref Register register, RequestAsyncResult result) : base(participant)
 {
     this.register = register;
     this.result = result;
 }
 private void SendRegister(CoordinatorEnlistment coordinator, ControlProtocol protocol, EndpointAddress protocolService, AsyncCallback callback, object callbackState)
 {
     Register register = new Register(this.state.ProtocolVersion) {
         Protocol = protocol,
         Loopback = this.state.ProcessId,
         ParticipantProtocolService = protocolService,
         SupportingToken = coordinator.SuperiorIssuedToken
     };
     if (DebugTrace.Info)
     {
         DebugTrace.TxTrace(TraceLevel.Info, coordinator.EnlistmentId, "Sending Register for {0} to {1}", protocol, Ports.TryGetAddress(coordinator.RegistrationProxy));
     }
     IAsyncResult ar = coordinator.RegistrationProxy.BeginSendRegister(ref register, callback, callbackState);
     if (ar.CompletedSynchronously)
     {
         this.OnSendRegisterComplete(coordinator, protocol, ar);
     }
 }
        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");
        }
        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");
        }