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

                            //------------------------------------------------------------------------------ 
// Copyright (c) Microsoft Corporation.  All rights reserved.
//-----------------------------------------------------------------------------
//
// Presharp uses the c# pragma mechanism to supress its warnings. 
// These are not recognised by the base compiler so we need to explictly
// disable the following warnings. See http://winweb/cse/Tools/PREsharp/userguide/default.asp 
// for details. 
//
#pragma warning disable 1634, 1691      // unknown message, unknown pragma 



namespace Microsoft.InfoCards 
{
    using System; 
    using System.Collections.Generic; 
    using System.ComponentModel;
    using System.Diagnostics; 
    using System.Reflection;
    using System.Security.Principal;
    using System.Runtime.InteropServices;
    using System.IO; 
    using Microsoft.InfoCards.Diagnostics;
    using IDT = Microsoft.InfoCards.Diagnostics.InfoCardTrace; 
 
    internal class RequestFactory
    { 

        //
        // The request names we support. Used to map incoming strings to an integer we
        // can O(1) switch case on. 
        //
        private enum RequestName 
        { 
            CloseCryptoHandleRequest = 0,
            DecryptRequest, 
            EncryptRequest,
            GenerateDerivedKeyRequest,
            GetBrowserTokenRequest,
            GetCryptoTransformRequest, 
            GetKeyedHashRequest,
            GetTokenRequest, 
            HashCoreRequest, 
            HashFinalRequest,
            ImportRequest, 
            ManageRequest,
            SignHashRequest,
            TransformBlockRequest,
            TransformFinalBlockRequest, 
            VerifyHashRequest,
            ClientRequestCount = VerifyHashRequest - CloseCryptoHandleRequest + 1, 
 
            BeginCreateSecurityTokenRequest = 0x80,
            BeginSelectCardRequest, 
            CancelAsyncOperationRequest,
            CreateCardRequest,
            CheckStoreFileValidityRequest,
            DeleteCardRequest, 
            DeleteStoreRequest,
            EndCreateSecurityTokenRequest, 
            EndSelectCardRequest, 
            ExportFileRequest,
            GetCertificateRequest, 
            GetImportedCardRequest,
            GetImportFileNameRequest,
            GetLedgerEntryForRecipientRequest,
            GetLedgerRequest, 
            GetPolicyDetailsRequest,
            GetRecipientListRequest, 
            GetRecipientRequest, 
            GetUserPreferenceRequest,
            ImportFileRequest, 
            InfoCardListRequest,
            ListCardsInFileRequest,
            QueryStoreStatusRequest,
            ResolvePPIDRequest, 
            SaveCardRequest,
            SaveLedgerEntryRequest, 
            SaveRecipientRequest, 
            SendAgentStatusRequest,
            SetUserPreferenceRequest, 
            UIEndRequest,
            BeginGetFileNameFromUserRequest,
            EndGetFileNameFromUserRequest,
            ListDependantCardsRequest, 
            GetLastErrorDetailsRequest,
            GetIsBrowserClientRequest, 
            SetUserLanguageRequest, 
            GetCardDetailsRequest,
            UnlockCardRequest, 
            AgentRequestCount = UnlockCardRequest - BeginCreateSecurityTokenRequest + 1
        }
        static readonly RequestName[] s_uiClientRequests =
        { 
            RequestName.GetBrowserTokenRequest,
            RequestName.GetTokenRequest, 
            RequestName.ImportRequest, 
            RequestName.ManageRequest
        }; 

        //
        // Set max request blob size.
        // 
        // Remarks: 20 MB. 2MB was not sufficient to import 100 cards.
        // 
        const int MaxRequestBlobSize = 20 * 1024 * 1024; 

        // 
        // The max request type string size is set in idl to be 100 wchars.
        //

        static object s_createRequestSync = new object(); 

        static Dictionary< string, RequestName> s_requestMap; 
        // 
        // Summary:
        //   This class should not be instantiated 
        //
        private RequestFactory ()
        {
 

        } 
 
        //
        // Summary: 
        // Configures the string to id mapping that we use to ensure the
        // swtich statement is O(1)
        //
 
        static RequestFactory()
        { 
            s_requestMap = new Dictionary< string, RequestName>( (int)RequestName.ClientRequestCount + (int)RequestName.AgentRequestCount ); 

            // 
            // First the client requests.
            //
            s_requestMap[ "CloseCryptoHandleRequest" ]          = RequestName.CloseCryptoHandleRequest;
            s_requestMap[ "DecryptRequest" ]                    = RequestName.DecryptRequest; 
            s_requestMap[ "EncryptRequest" ]                    = RequestName.EncryptRequest;
            s_requestMap[ "GenerateDerivedKeyRequest" ]         = RequestName.GenerateDerivedKeyRequest; 
            s_requestMap[ "GetBrowserTokenRequest" ]            = RequestName.GetBrowserTokenRequest; 
            s_requestMap[ "GetCryptoTransformRequest" ]         = RequestName.GetCryptoTransformRequest;
            s_requestMap[ "GetKeyedHashRequest" ]               = RequestName.GetKeyedHashRequest; 
            s_requestMap[ "GetTokenRequest" ]                   = RequestName.GetTokenRequest;
            s_requestMap[ "HashCoreRequest" ]                   = RequestName.HashCoreRequest;
            s_requestMap[ "HashFinalRequest" ]                  = RequestName.HashFinalRequest;
            s_requestMap[ "ImportRequest" ]                     = RequestName.ImportRequest; 
            s_requestMap[ "ManageRequest" ]                     = RequestName.ManageRequest;
            s_requestMap[ "SignHashRequest" ]                   = RequestName.SignHashRequest; 
            s_requestMap[ "TransformBlockRequest" ]             = RequestName.TransformBlockRequest; 
            s_requestMap[ "TransformFinalBlockRequest" ]        = RequestName.TransformFinalBlockRequest;
            s_requestMap[ "VerifyHashRequest" ]                 = RequestName.VerifyHashRequest; 

            //
            // And the agent requests.
            // 
            s_requestMap[ "BeginCreateSecurityTokenRequest" ]   = RequestName.BeginCreateSecurityTokenRequest;
            s_requestMap[ "BeginSelectCardRequest" ]            = RequestName.BeginSelectCardRequest; 
            s_requestMap[ "CancelAsyncOperationRequest" ]       = RequestName.CancelAsyncOperationRequest; 
            s_requestMap[ "CheckStoreFileValidityRequest" ]     = RequestName.CheckStoreFileValidityRequest;
            s_requestMap[ "CreateCardRequest" ]                 = RequestName.CreateCardRequest; 
            s_requestMap[ "DeleteCardRequest" ]                 = RequestName.DeleteCardRequest;
            s_requestMap[ "DeleteStoreRequest"]                 = RequestName.DeleteStoreRequest;
            s_requestMap[ "EndCreateSecurityTokenRequest" ]     = RequestName.EndCreateSecurityTokenRequest;
            s_requestMap[ "EndSelectCardRequest" ]              = RequestName.EndSelectCardRequest; 
            s_requestMap[ "ExportFileRequest" ]                 = RequestName.ExportFileRequest;
            s_requestMap[ "GetCertificateRequest" ]             = RequestName.GetCertificateRequest; 
            s_requestMap[ "GetImportedCardRequest" ]            = RequestName.GetImportedCardRequest; 
            s_requestMap[ "GetImportFileNameRequest" ]          = RequestName.GetImportFileNameRequest;
            s_requestMap[ "GetLedgerEntryForRecipientRequest" ] = RequestName.GetLedgerEntryForRecipientRequest; 
            s_requestMap[ "GetLedgerRequest" ]                  = RequestName.GetLedgerRequest;
            s_requestMap[ "GetPolicyDetailsRequest" ]           = RequestName.GetPolicyDetailsRequest;
            s_requestMap[ "GetRecipientListRequest" ]           = RequestName.GetRecipientListRequest;
            s_requestMap[ "GetRecipientRequest" ]               = RequestName.GetRecipientRequest; 
            s_requestMap[ "GetUserPreferenceRequest" ]          = RequestName.GetUserPreferenceRequest;
            s_requestMap[ "ImportFileRequest" ]                 = RequestName.ImportFileRequest; 
            s_requestMap[ "InfoCardListRequest" ]               = RequestName.InfoCardListRequest; 
            s_requestMap[ "ListCardsInFileRequest" ]            = RequestName.ListCardsInFileRequest;
            s_requestMap[ "QueryStoreStatusRequest" ]           = RequestName.QueryStoreStatusRequest; 
            s_requestMap[ "ResolvePPIDRequest" ]                = RequestName.ResolvePPIDRequest;
            s_requestMap[ "SaveCardRequest" ]                   = RequestName.SaveCardRequest;
            s_requestMap[ "SaveLedgerEntryRequest" ]            = RequestName.SaveLedgerEntryRequest;
            s_requestMap[ "SaveRecipientRequest" ]              = RequestName.SaveRecipientRequest; 
            s_requestMap[ "SendAgentStatusRequest" ]            = RequestName.SendAgentStatusRequest;
            s_requestMap[ "SetUserPreferenceRequest" ]          = RequestName.SetUserPreferenceRequest; 
            s_requestMap[ "BeginGetFileNameFromUserRequest" ]   = RequestName.BeginGetFileNameFromUserRequest; 
            s_requestMap[ "EndGetFileNameFromUserRequest" ]     = RequestName.EndGetFileNameFromUserRequest;
            s_requestMap[ "UIEndRequest" ]                      = RequestName.UIEndRequest; 
            s_requestMap[ "ListDependantCardsRequest" ]         = RequestName.ListDependantCardsRequest;
            s_requestMap[ "GetLastErrorDetailsRequest" ]        = RequestName.GetLastErrorDetailsRequest;
            s_requestMap[ "GetIsBrowserClientRequest" ]        =  RequestName.GetIsBrowserClientRequest;
            s_requestMap[ "SetUserLanguageRequest" ]            = RequestName.SetUserLanguageRequest; 
            s_requestMap[ "GetCardDetailsRequest" ]             = RequestName.GetCardDetailsRequest;
            s_requestMap[ "UnlockCardRequest" ]                 = RequestName.UnlockCardRequest; 
        } 

 
        //
        // Summary:
        //   Primary entry point from native code for all incoming RPC requests.
        //   1) Determines if this is a UIAgent Request or a Client Request, 
        //   2) Instantiates the appropriate request class
        //   3) Calls DoProcess on that request 
        //   4) Calls ConvertStreamToIntPtr to convert out stream into an IntPtr that 
        //      can be handed out to native code.
        // 
        //
        // Args:
        //   parentRequestHandle - represents the parent request of this reuqest (if any)
        //   rpcHandle - handle to the RPC call 
        //   inArgs- represents input data stream
        //   outArgs - represents output data stream 
        // 
        internal static int ProcessNewRequest (
                                int parentRequestHandle, 
                                IntPtr rpcHandle,
                                IntPtr inArgs,
                                out IntPtr outArgs )
        { 

            // 
            // If the current thread is already impersonating, then the thread management logic 
            // has gone badly wrong and we can no longer be sure that we will be running under the
            // correct user's context. 
            //
            IDT.Assert( null == WindowsIdentity.GetCurrent( true ), "unexpected user context on incoming thread" );

            int err = 0; 
            outArgs = IntPtr.Zero;
 
            if( IntPtr.Zero == inArgs ) 
            {
                return (int) EventCode.E_ICARD_COMMUNICATION; 
            }
            if( IntPtr.Zero == rpcHandle )
            {
                return (int) EventCode.E_ICARD_COMMUNICATION; 
            }
 
            try 
            {
                RpcRequest request; 
                RpcResponse outResponse;

                request = ( RpcRequest ) Marshal.PtrToStructure( inArgs, typeof( RpcRequest ) );
 
                //
                // We do not expect to have requests greater than MaxRequestBlobSize. 
                // Also the request type should not be null. 
                //
 
                //
                // IntPtr semantics have changed so null == myIntPtr compiles fine but does not do what's expected.
                //
 

                if (    request.Length < 0 
                        || request.Length > MaxRequestBlobSize 
                        || null == request.Type
                        || ( request.Length > 0 && IntPtr.Zero == request.Data ) ) 
                {
                    return (int) EventCode.E_ICARD_COMMUNICATION;
                }
 
                Stream inStream;
 
                if( 0 != request.Length ) 
                {
                    byte [] inBytes = new byte [ request.Length ]; 
                    Marshal.Copy( request.Data, inBytes, 0, request.Length );
                    inStream = new MemoryStream( inBytes, 0, inBytes.Length, false, false );
                }
                else 
                {
                    inStream = new MemoryStream(); 
                } 

                MemoryStream outStream = new MemoryStream(); 
                //
                // Initialize string to get an extended error message, if any.
                // For Client messages the extended error message does not get passed.
                // 
                string extendedErrorMessage;
 
                if( 0 == parentRequestHandle ) 
                {
                    // 
                    // Get a monitor handle ready in case the client request needs to create a UIAgent.
                    // If not then the monitor handle will do nothing.
                    //
                    using( UIAgentMonitorHandle monitorHandle = new UIAgentMonitorHandle() ) 
                    {
                        // 
                        // This must be a ClientRequest since it's parentRequestHandle is null 
                        //
                        using( ClientRequest clientRequest = CreateClientRequestInstance( 
                                            monitorHandle, request.Type, rpcHandle, inStream, outStream ) )
                        {

                            // 
                            // Process the request as the user.
                            // 
                            err = clientRequest.DoProcessRequest( out extendedErrorMessage ); 
                            ConvertStreamToIntPtr( outStream, out outResponse );
                            outArgs = outResponse.Marshal(); 

                            //
                            // Disposal of the client request will undo the impersonation context.
                            // 
                        }
                    } 
                } 
                else
                { 
                    //
                    // Called from native code for UIAgentRequests
                    //
                    ClientUIRequest parentRequest = ( ClientUIRequest ) 
                        Request.FindRequestByHandle( parentRequestHandle );
 
                    IDT.Assert( null != parentRequest, "ParentRequest is null" ); 

                    using( UIAgentRequest uiAgentRequest = CreateUIAgentRequestInstance( 
                                        parentRequest, request.Type, rpcHandle, inStream, outStream ) )
                    {

                        // 
                        // Process the request as the user.
                        // If an error occurs then the extended message is written out 
                        // 
                        err = uiAgentRequest.DoProcessRequest( out extendedErrorMessage );
                        if( 0 != err ) 
                        {
                            BinaryWriter writer = new BinaryWriter( outStream, System.Text.Encoding.Unicode );
                            Utility.SerializeString( writer, extendedErrorMessage );
                        } 
                        ConvertStreamToIntPtr( outStream, out outResponse );
                        outArgs = outResponse.Marshal(); 
 
                        //
                        // Disposal of the uiAgentRequest will undo the impersonation. 
                        //
                    }
                }
            } 
            catch( TargetInvocationException tie )
            { 
                if( null != tie.InnerException && tie.InnerException is InfoCardBaseException ) 
                {
                    // 
                    // We threw an infocard exception, which was not handled durring processes.
                    //  It typically happens during construction of the request
                    //
                    err = ( ( InfoCardBaseException ) tie.InnerException ).NativeHResult; 
                }
                else 
                { 
                    InfoCardService.Crash( tie );
                } 
            }
            catch( InfoCardBaseException ibe )
            {
                // 
                // TargetInvocationException takes care of exceptions thrown
                // during construction. But this is for exceptions thrown 
                // during the intialization phase of a 
                // client request.
                // 
                err = ibe.NativeHResult;
            }
            catch( OutOfMemoryException )
            { 
                //
                // This is for example if byte [] inBytes = new byte [ request.Length ]; 
                // fails for example in the event of a decently large request.Length. 
                // (NB: For OutOfMemoryExceptions that are happenning during processing of the
                // request, we currently crash in OnHandleExceptions.) 
                //
                err = (int) EventCode.E_OUTOFMEMORY;
            }
            catch ( EndOfStreamException ) 
            {
                err = (int) EventCode.E_ICARD_MALFORMED_REQUEST; 
            } 
#pragma warning disable 56500       // do not catch non-recoverable exceptions
            catch( Exception e ) 
            {
                IDT.TraceAndLogException( e );
                //
                // We don't expect to get exceptions at this point.  They should have already been handled. 
                //
                InfoCardService.Crash( e ); 
            } 

#pragma warning restore 56500 

            return err;
        }
 
        //
        // Summary: 
        //   Move data in output stream to global memory pointed to by an RpcResponse struct 
        //
        // Args: 
        //   outStream - contains the data that needs to be moved to global memory
        //   outArgs - pointer to the RpcResponse object (points to global memory)
        //
        private static void ConvertStreamToIntPtr( MemoryStream outStream, out RpcResponse outArgs ) 
        {
            byte[] outByte = outStream.GetBuffer(); 
            outArgs = new RpcResponse(); 
            outArgs.Length = 0;
            outArgs.Data = IntPtr.Zero; 

            if( null != outByte && outByte.Length != 0 )
            {
                IntPtr rpcResponseBytes = Marshal.AllocHGlobal( outByte.Length ); 
                Marshal.Copy( outByte, 0, rpcResponseBytes, outByte.Length );
                outArgs.Data = rpcResponseBytes; 
                outArgs.Length = outByte.Length; 
            }
        } 


        //
        // Summary: 
        //   Create an instance of a ClientRequest using the appropriate RequestConstructor in the s_requestMap
        // 
        // Args: 
        //   reqName - the name of the request type that we want to create
        //   rpcHandle - handle to the ui agent RPC call 
        //   inStream - represents input data stream
        //   outStream - represents output data stream
        //
        private static ClientRequest CreateClientRequestInstance( 
            UIAgentMonitorHandle monitorHandle,
            string reqName, 
            IntPtr rpcHandle, 
            Stream inStream,
            Stream outStream ) 
        {
            ClientRequest request = null;
            lock( s_createRequestSync )
            { 
                IDT.TraceDebug( "Starting incoming client request type {0} " , reqName );
 
                if( String.IsNullOrEmpty( reqName ) ) 
                {
                    throw IDT.ThrowHelperError( new CommunicationException() ); 
                }

                if( !s_requestMap.ContainsKey( reqName ) )
                { 
                    throw IDT.ThrowHelperError( new CommunicationException() );
                } 
 

 


                RequestName name = s_requestMap[ reqName ];
 

                if( -1 != Array.IndexOf( s_uiClientRequests, name ) ) 
                { 
                    Process callingProcess = ClientUIRequest.GetContextMapping( rpcHandle, true );
 
                    IDT.ThrowInvalidArgumentConditional( null == callingProcess, "rpcHandle" );

                    int tsSessionId = 0;
                    if( !NativeMethods.ProcessIdToSessionId( (int)callingProcess.Id, out tsSessionId ) ) 
                    {
                        int error = Marshal.GetLastWin32Error(); 
 
                        throw IDT.ThrowHelperError(
                                            new CommunicationException( 
                                                    SR.GetString( SR.ServiceErrorGettingClientTSSession ),
                                                    new Win32Exception( error ) ) );
                    }
 
                    WindowsIdentity identity = NativeMcppMethods.CreateServiceExecutionIdentity( callingProcess );
 
                    InfoCardUIAgent uiAgent = monitorHandle.CreateAgent( callingProcess.Id, identity, tsSessionId ); 

                    switch( s_requestMap[ reqName ] ) 
                    {
                        case RequestName.GetBrowserTokenRequest:
                            request = new GetBrowserTokenRequest( callingProcess, identity, uiAgent, rpcHandle, inStream, outStream );
                            break; 
                        case RequestName.GetTokenRequest :
                            request = new GetTokenRequest( callingProcess, identity, uiAgent,rpcHandle, inStream, outStream ); 
                            break; 
                        case RequestName.ImportRequest :
                            request = new ImportRequest( callingProcess, identity, uiAgent, rpcHandle, inStream, outStream ); 
                            break;
                        case RequestName.ManageRequest :
                            request = new ManageRequest( callingProcess, identity, uiAgent, rpcHandle, inStream, outStream );
                            break; 
                        default:
                            // 
                            // Bad request - not a request we handle 
                            //
                            throw IDT.ThrowHelperError( new CommunicationException() ); 
                    }
                }
                else
                { 
                    Process callingProcess = ClientRequest.GetCallingProcessFromRpcHandle( rpcHandle );
                    WindowsIdentity identity = NativeMcppMethods.CreateServiceExecutionIdentity( callingProcess ); 
                    switch( s_requestMap[ reqName ] ) 
                    {
                        case RequestName.CloseCryptoHandleRequest : 
                            request = new CloseCryptoHandleRequest( callingProcess, identity, rpcHandle, inStream, outStream );
                            break;
                        case RequestName.DecryptRequest :
                            request = new DecryptRequest( callingProcess, identity, rpcHandle, inStream, outStream ); 
                            break;
                        case RequestName.EncryptRequest : 
                            request = new EncryptRequest( callingProcess, identity, rpcHandle, inStream, outStream ); 
                            break;
                        case RequestName.GenerateDerivedKeyRequest : 
                            request = new GenerateDerivedKeyRequest( callingProcess, identity, rpcHandle, inStream, outStream );
                            break;
                        case RequestName.GetCryptoTransformRequest :
                            request = new GetCryptoTransformRequest( callingProcess, identity, rpcHandle, inStream, outStream ); 
                            break;
                        case RequestName.GetKeyedHashRequest : 
                            request = new GetKeyedHashRequest( callingProcess, identity, rpcHandle, inStream, outStream ); 
                            break;
                        case RequestName.HashCoreRequest : 
                            request = new HashCoreRequest( callingProcess, identity, rpcHandle, inStream, outStream );
                            break;
                        case RequestName.HashFinalRequest :
                            request = new HashFinalRequest( callingProcess, identity, rpcHandle, inStream, outStream ); 
                            break;
                        case RequestName.SignHashRequest : 
                            request = new SignHashRequest( callingProcess, identity, rpcHandle, inStream, outStream ); 
                            break;
                        case RequestName.TransformBlockRequest : 
                            request = new TransformBlockRequest( callingProcess, identity, rpcHandle, inStream, outStream );
                            break;
                        case RequestName.TransformFinalBlockRequest :
                            request = new TransformFinalBlockRequest( callingProcess, identity, rpcHandle, inStream, outStream ); 
                            break;
                        case RequestName.VerifyHashRequest : 
                            request = new VerifyHashRequest( callingProcess, identity, rpcHandle, inStream, outStream ); 
                            break;
 
                        default:
                            //
                            // Bad request - not a request we handle
                            // 
                            throw IDT.ThrowHelperError( new CommunicationException() );
                    } 
                } 
                request.Initialize();
            } 

            return request;
        }
 

        // 
        // Summary: 
        //   Create an instance of a UIAgentRequest using the appropriate RequestConstructor in the s_requestMap
        // 
        // Args:
        //   parentRequest - the parent request this UIAgentRequest is associated with
        //   reqName - the name of the request type that we want to create
        //   rpcHandle - handle to the ui agent RPC call 
        //   inStream - represents input data stream
        //   outStream - represents output data stream 
        // 
        private static UIAgentRequest CreateUIAgentRequestInstance(
            ClientUIRequest parentRequest, 
            string reqName,
            IntPtr rpcHandle,
            Stream inStream,
            Stream outStream ) 
        {
            UIAgentRequest request = null; 
            lock( s_createRequestSync ) 
            {
                IDT.TraceDebug( "Starting incoming request type {0}", reqName ); 

                //
                // DO NOT ASSERT FOR null != s_requestMap[ reqName ].
                // as this will throw KeyNotFoundException on debug bits 
                //
 
                IDT.Assert( !String.IsNullOrEmpty( reqName ), "Null or empty request name" ); 
                IDT.Assert( s_requestMap.ContainsKey( reqName ), "Request map does not contain " + reqName );
 

                switch( s_requestMap[ reqName ] )
                {
                    case RequestName.GetIsBrowserClientRequest: 
                        request = new GetIsBrowserClientRequest( rpcHandle, inStream, outStream, parentRequest );
                        break; 
                    case RequestName.GetLastErrorDetailsRequest: 
                        request = new GetLastErrorDetailsRequest( rpcHandle, inStream, outStream, parentRequest );
                        break; 
                    case RequestName.BeginCreateSecurityTokenRequest:
                        request = new BeginCreateSecurityTokenRequest( rpcHandle, inStream, outStream, parentRequest );
                        break;
                    case RequestName.BeginSelectCardRequest: 
                        request = new BeginSelectCardRequest( rpcHandle, inStream, outStream, parentRequest );
                        break; 
                    case RequestName.CancelAsyncOperationRequest : 
                        request = new CancelAsyncOperationRequest( rpcHandle, inStream, outStream, parentRequest );
                        break; 
                    case RequestName.CheckStoreFileValidityRequest:
                        request = new CheckStoreFileValidityRequest( rpcHandle, inStream, outStream, parentRequest );
                        break;
                    case RequestName.CreateCardRequest : 
                        request = new CreateCardRequest( rpcHandle, inStream, outStream, parentRequest );
                        break; 
                    case RequestName.DeleteCardRequest : 
                        request = new DeleteCardRequest( rpcHandle, inStream, outStream, parentRequest );
                        break; 
                    case RequestName.DeleteStoreRequest :
                        request = new DeleteStoreRequest( rpcHandle, inStream, outStream, parentRequest );
                        break;
                    case RequestName.EndCreateSecurityTokenRequest : 
                        request = new EndCreateSecurityTokenRequest( rpcHandle, inStream, outStream, parentRequest );
                        break; 
                    case RequestName.EndSelectCardRequest : 
                        request = new EndSelectCardRequest( rpcHandle, inStream, outStream, parentRequest );
                        break; 
                    case RequestName.ExportFileRequest :
                        request = new ExportFileRequest( rpcHandle, inStream, outStream, parentRequest );
                        break;
                    case RequestName.GetCertificateRequest : 
                        request = new GetCertificateRequest( rpcHandle, inStream, outStream, parentRequest );
                        break; 
                    case RequestName.GetImportedCardRequest : 
                        request = new GetImportedCardRequest( rpcHandle, inStream, outStream, parentRequest );
                        break; 
                    case RequestName.GetImportFileNameRequest :
                        request = new GetImportFileNameRequest( rpcHandle, inStream, outStream, parentRequest );
                        break;
                     case RequestName.GetLedgerEntryForRecipientRequest : 
                        request = new GetLedgerEntryForRecipientRequest( rpcHandle, inStream, outStream, parentRequest );
                        break; 
                    case RequestName.GetLedgerRequest : 
                        request = new GetLedgerRequest( rpcHandle, inStream, outStream, parentRequest );
                        break; 
                    case RequestName.GetPolicyDetailsRequest :
                        request = new GetPolicyDetailsRequest( rpcHandle, inStream, outStream, parentRequest );
                        break;
                    case RequestName.GetRecipientListRequest : 
                        request = new GetRecipientListRequest( rpcHandle, inStream, outStream, parentRequest );
                        break; 
                    case RequestName.GetRecipientRequest : 
                        request = new GetRecipientRequest( rpcHandle, inStream, outStream, parentRequest );
                        break; 
                    case RequestName.GetUserPreferenceRequest :
                        request = new GetUserPreferenceRequest( rpcHandle, inStream, outStream, parentRequest );
                        break;
                    case RequestName.ImportFileRequest : 
                        request = new ImportFileRequest( rpcHandle, inStream, outStream, parentRequest );
                        break; 
                    case RequestName.InfoCardListRequest : 
                        request = new InfoCardListRequest( rpcHandle, inStream, outStream, parentRequest );
                        break; 
                    case RequestName.ListCardsInFileRequest :
                        request = new ListCardsInFileRequest( rpcHandle, inStream, outStream, parentRequest );
                        break;
                    case RequestName.QueryStoreStatusRequest : 
                        request = new QueryStoreStatusRequest( rpcHandle, inStream, outStream, parentRequest );
                        break; 
                    case RequestName.ResolvePPIDRequest : 
                        request = new ResolvePPIDRequest( rpcHandle, inStream, outStream, parentRequest );
                        break; 
                    case RequestName.SaveCardRequest :
                        request = new SaveCardRequest( rpcHandle, inStream, outStream, parentRequest );
                        break;
                    case RequestName.SaveLedgerEntryRequest: 
                        request = new SaveLedgerEntryRequest( rpcHandle, inStream, outStream, parentRequest );
                        break; 
                    case RequestName.SaveRecipientRequest : 
                        request = new SaveRecipientRequest( rpcHandle, inStream, outStream, parentRequest );
                        break; 
                    case RequestName.SetUserPreferenceRequest :
                        request = new SetUserPreferenceRequest( rpcHandle, inStream, outStream, parentRequest );
                        break;
                    case RequestName.SendAgentStatusRequest : 
                        request = new SendAgentStatusRequest( rpcHandle, inStream, outStream, parentRequest );
                        break; 
                    case RequestName.UIEndRequest : 
                        request = new UIEndRequest( rpcHandle, inStream, outStream, parentRequest );
                        break; 
                    case RequestName.BeginGetFileNameFromUserRequest :
                        request = new BeginGetFileNameFromUserRequest( rpcHandle, inStream, outStream, parentRequest );
                        break;
                    case RequestName.EndGetFileNameFromUserRequest : 
                        request = new EndGetFileNameFromUserRequest( rpcHandle, inStream, outStream, parentRequest );
                        break; 
                    case RequestName.ListDependantCardsRequest: 
                        request = new ListDependantCardsRequest( rpcHandle, inStream, outStream, parentRequest );
                        break; 
                    case RequestName.SetUserLanguageRequest:
                        request = new SetUserLanguageRequest( rpcHandle, inStream, outStream, parentRequest );
                        break;
                    case RequestName.GetCardDetailsRequest: 
                        request = new GetCardDetailsRequest( rpcHandle, inStream, outStream, parentRequest );
                        break; 
                    case RequestName.UnlockCardRequest: 
                        request = new UnlockCardRequest( rpcHandle, inStream, outStream, parentRequest );
                        break; 

                    default:
                        //
                        // Bad request - not a request we handle 
                        //
                        throw IDT.ThrowHelperError( new CommunicationException() ); 
                } 

                request.Initialize(); 
            }
            return request;
        }
 
    }
} 

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