RpcCryptoRequest.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 / infocard / Service / managed / Microsoft / InfoCards / RpcCryptoRequest.cs / 1 / RpcCryptoRequest.cs

                            //------------------------------------------------------------------------------ 
// Copyright (c) Microsoft Corporation.  All rights reserved.
//-----------------------------------------------------------------------------
namespace Microsoft.InfoCards
{ 
    using System;
    using System.IO; 
    using System.ComponentModel; 
    using System.Runtime.InteropServices;
    using Microsoft.InfoCards.Diagnostics; 
    using IDT = Microsoft.InfoCards.Diagnostics.InfoCardTrace;

    //
    // Summary: 
    //  Abstract client request class for RpcCrypto interface
    // 
    abstract class RpcCryptoRequest 
    {
        RpcCryptoContext m_context; 


        //
        // Summary: 
        //  Base request Ctor:
        // 
        protected RpcCryptoRequest( RpcCryptoContext context ) 
        {
            m_context = context; 
        }

        //
        // Summary: 
        //  Implementers request name.
        // 
        public abstract string Name{get;} 

 

        //
        // Summary:
        //  Process the request. 
        //
        public void Process() 
        { 
            MemoryStream ms = new MemoryStream();
 
            MarshalOutArgs( ms );

            byte[] buffer = ms.GetBuffer();
            byte[] returnBuffer = null; 
            //
            // Translate the win32 exceptions into a communication exception, 
            //  as if it occurs, 
            //
            try 
            {
                returnBuffer = NativeMcppMethods.RpcCryptoDispatchRequest(
                                                            m_context.InterfaceHandle,
                                                            m_context.ContextKey, 
                                                            Name,
                                                            buffer, 
                                                            0, 
                                                            Convert.ToInt32( ms.Length ) );
            } 
            catch( Win32Exception we )
            {
                if( we.NativeErrorCode == (int) EventCode.SCARD_W_CANCELLED_BY_USER )
                { 
                    throw IDT.ThrowHelperError( new UserCancelledException( null, we ) );
                } 
                else 
                {
                    throw IDT.ThrowHelperError( new CommunicationException( null, we ) ); 
                }
            }

            ms = new MemoryStream( returnBuffer ); 

            MarshalReturnArgs( ms ); 
        } 

        protected abstract void MarshalOutArgs( Stream stream ); 
        protected abstract void MarshalReturnArgs( Stream stream );

    }
} 


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