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
 public static bool TryGetCallbackCorrelationHandle(this Collection <CorrelationInitializer> correlationInitializers, NativeActivityContext context, out CorrelationHandle correlationHandle)
 {
     correlationHandle = CorrelationHandle.GetExplicitCallbackCorrelation(context, correlationInitializers);
     return(correlationHandle != null);
 }