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

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

// Define the interfaces and infrastructure needed to send registration messages 

using System; 
using System.ServiceModel.Channels; 
using System.Diagnostics;
using System.ServiceModel; 

namespace Microsoft.Transactions.Wsat.Messaging
{
    class RegistrationProxy : RequestReplyProxy 
    {
        public RegistrationProxy(CoordinationService coordination, 
                                 EndpointAddress to) 
            :
            base (coordination, to) {} 

        protected override IChannelFactory SelectChannelFactory(out MessageVersion messageVersion)
        {
            messageVersion = this.coordinationService.InteropRegistrationBinding.MessageVersion; 
            return this.coordinationService.InteropRegistrationChannelFactory;
        } 
 
        RegisterMessage CreateRegisterMessage (ref Register register)
        { 
            RegisterMessage message = new RegisterMessage(this.messageVersion, ref register);
            if (register.SupportingToken != null)
            {
                CoordinationServiceSecurity.AddSupportingToken(message, register.SupportingToken); 
            }
            return message; 
        } 

        public RegisterResponse SendRegister (ref Register register) 
        {
            if (DebugTrace.Verbose)
            {
                DebugTrace.Trace(TraceLevel.Verbose, "Sending Register to {0}", this.to.Uri); 
            }
 
            Message message = CreateRegisterMessage(ref register); 
            Message reply = SendRequest(message, this.coordinationStrings.RegisterResponseAction);
 
            using (reply)
            {
                if (DebugTrace.Verbose)
                { 
                    DebugTrace.Trace(TraceLevel.Verbose, "Dispatching RegisterResponse reply");
                    if (DebugTrace.Pii) 
                        DebugTrace.TracePii(TraceLevel.Verbose, 
                                            "Sender is {0}",
                                            CoordinationServiceSecurity.GetSenderName(reply)); 
                }

                return new RegisterResponse(reply, this.protocolVersion);
            } 
        }
 
        public IAsyncResult BeginSendRegister (ref Register register, AsyncCallback callback, object state) 
        {
            if (DebugTrace.Verbose) 
            {
                DebugTrace.Trace(TraceLevel.Verbose, "Sending Register to {0}", this.to.Uri);
            }
 
            Message message = CreateRegisterMessage (ref register);
            return BeginSendRequest (message, callback, state); 
        } 

        public RegisterResponse EndSendRegister (IAsyncResult ar) 
        {
            try
            {
                Message reply = EndSendRequest(ar, this.coordinationStrings.RegisterResponseAction); 
                using (reply)
                { 
                    if (DebugTrace.Verbose) 
                    {
                        DebugTrace.Trace(TraceLevel.Verbose, "Dispatching RegisterResponse reply"); 
                        if (DebugTrace.Pii)
                            DebugTrace.TracePii(TraceLevel.Verbose,
                                                "Sender is {0}",
                                                CoordinationServiceSecurity.GetSenderName(reply)); 
                    }
 
                    return new RegisterResponse(reply, this.protocolVersion); 
                }
            } 
            catch (CommunicationException e)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new WsatReceiveFailureException(e));
            } 
        }
 
        public static void SendRegisterResponse (RequestAsyncResult result, ref RegisterResponse response) 
        {
            Message message = new RegisterResponseMessage (result.MessageVersion, ref response); 
            result.Finished (message);
        }

        public static void SendFaultResponse (RequestAsyncResult result, Fault fault) 
        {
            Library.SendFaultResponse (result, fault); 
        } 
    }
} 

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