private void ServerScheduleOnReceivedMessage(NativeActivityContext executionContext, ReceiveMessageInstanceData instance)
        {
            System.ServiceModel.Channels.Message message = instance.CorrelationResponseContext.WorkflowOperationContext.Inputs[0] as System.ServiceModel.Channels.Message;
            this.Message.Set(executionContext, message);
            instance.CorrelationResponseContext.MessageVersion = ((System.ServiceModel.Channels.Message)instance.CorrelationResponseContext.WorkflowOperationContext.Inputs[0]).Version;
            CorrelationHandle ambientCorrelation = instance.GetAmbientCorrelation(executionContext);
            CorrelationHandle selectHandle       = (this.CorrelatesWith == null) ? null : this.CorrelatesWith.Get(executionContext);

            MessagingActivityHelper.InitializeCorrelationHandles(executionContext, selectHandle, ambientCorrelation, this.correlationInitializers, instance.CorrelationResponseContext.WorkflowOperationContext.OperationContext.IncomingMessageProperties);
            CorrelationHandle explicitChannelCorrelation = CorrelationHandle.GetExplicitChannelCorrelation(executionContext, this.correlationInitializers);

            if (this.IsOneWay)
            {
                if (explicitChannelCorrelation != null)
                {
                    throw System.ServiceModel.Activities.FxTrace.Exception.AsError(new InvalidOperationException(System.ServiceModel.Activities.SR.RequestReplyHandleShouldNotBePresentForOneWay));
                }
                if (this.NoPersistHandle != null)
                {
                    System.Activities.NoPersistHandle handle4 = this.NoPersistHandle.Get(executionContext);
                    if (handle4 != null)
                    {
                        handle4.Enter(executionContext);
                    }
                }
            }
            else if (explicitChannelCorrelation != null)
            {
                if (!explicitChannelCorrelation.TryRegisterResponseContext(executionContext, instance.CorrelationResponseContext))
                {
                    throw System.ServiceModel.Activities.FxTrace.Exception.AsError(new InvalidOperationException(System.ServiceModel.Activities.SR.TryRegisterRequestContextFailed));
                }
            }
            else if (!ambientCorrelation.TryRegisterResponseContext(executionContext, instance.CorrelationResponseContext))
            {
                throw System.ServiceModel.Activities.FxTrace.Exception.AsError(new InvalidOperationException(System.ServiceModel.Activities.SR.ReceiveMessageNeedsToPairWithSendMessageForTwoWayContract(this.OperationName)));
            }
            if (instance.CorrelationCallbackContext != null)
            {
                CorrelationHandle explicitCallbackCorrelation = CorrelationHandle.GetExplicitCallbackCorrelation(executionContext, this.correlationInitializers);
                if (explicitCallbackCorrelation == null)
                {
                    explicitCallbackCorrelation = ambientCorrelation;
                }
                if (explicitCallbackCorrelation != null)
                {
                    explicitCallbackCorrelation.CallbackContext = instance.CorrelationCallbackContext;
                }
            }
            this.FinalizeScheduleOnReceivedMessage(executionContext, instance);
        }
Exemple #2
0
 protected override void Execute(NativeActivityContext context)
 {
     System.ServiceModel.Channels.Message message = null;
     try
     {
         object[] emptyArray;
         message = this.Message.Get(context);
         if ((this.parameters == null) || (this.parameters.Count == 0))
         {
             emptyArray = System.ServiceModel.Activities.Constants.EmptyArray;
         }
         else
         {
             emptyArray = new object[this.parameters.Count];
         }
         this.Formatter.DeserializeRequest(message, emptyArray);
         if (this.parameters != null)
         {
             for (int i = 0; i < this.parameters.Count; i++)
             {
                 OutArgument argument = this.parameters[i];
                 object      defaultParameterValue = emptyArray[i];
                 if (defaultParameterValue == null)
                 {
                     defaultParameterValue = ProxyOperationRuntime.GetDefaultParameterValue(argument.ArgumentType);
                 }
                 argument.Set(context, defaultParameterValue);
             }
         }
     }
     finally
     {
         if (this.CloseMessage && (message != null))
         {
             message.Close();
         }
         this.Message.Set(context, null);
         System.Activities.NoPersistHandle handle = (this.NoPersistHandle == null) ? null : this.NoPersistHandle.Get(context);
         if (handle != null)
         {
             handle.Exit(context);
         }
     }
 }
 protected override void OnInitialize(HandleInitializationContext context)
 {
     this.noPersistHandle = context.CreateAndInitializeHandle<NoPersistHandle>();
     this.bookmarkScopeHandle = context.CreateAndInitializeHandle<BookmarkScopeHandle>();
 }