public void ApplyDispatchBehavior(OperationDescription operationDescription, DispatchOperation dispatchOperation)
        {
            if (operationDescription == null)
            {
                throw FxTrace.Exception.ArgumentNull("operationDescription");
            }
            if (dispatchOperation == null)
            {
                throw FxTrace.Exception.ArgumentNull("dispatchOperation");
            }
            if (dispatchOperation.Parent == null ||
                dispatchOperation.Parent.ChannelDispatcher == null ||
                dispatchOperation.Parent.ChannelDispatcher.Host == null ||
                dispatchOperation.Parent.ChannelDispatcher.Host.Description == null ||
                dispatchOperation.Parent.ChannelDispatcher.Host.Description.Behaviors == null)
            {
                throw FxTrace.Exception.AsError(new InvalidOperationException(SR.DispatchOperationInInvalidState));
            }

            ServiceHostBase serviceHost = dispatchOperation.Parent.ChannelDispatcher.Host;

            if (!(serviceHost is WorkflowServiceHost))
            {
                throw FxTrace.Exception.AsError(
                          new InvalidOperationException(SR.WorkflowBehaviorWithNonWorkflowHost(typeof(WorkflowOperationBehavior).Name)));
            }

            CorrelationKeyCalculator correlationKeyCalculator = null;

            ServiceEndpoint endpoint = null;

            foreach (ServiceEndpoint endpointToMatch in serviceHost.Description.Endpoints)
            {
                if (endpointToMatch.Id == dispatchOperation.Parent.EndpointDispatcher.Id)
                {
                    endpoint = endpointToMatch;
                    break;
                }
            }

            if (endpoint != null)
            {
                CorrelationQueryBehavior queryBehavior = endpoint.Behaviors.Find <CorrelationQueryBehavior>();

                if (queryBehavior != null)
                {
                    correlationKeyCalculator = queryBehavior.GetKeyCalculator();
                }
            }

            dispatchOperation.Invoker = new WorkflowOperationInvoker(operationDescription,
                                                                     endpoint, correlationKeyCalculator, this, serviceHost, dispatchOperation.Invoker);
        }
        public void ApplyDispatchBehavior(OperationDescription operationDescription, DispatchOperation dispatchOperation)
        {
            ServiceHostBase serviceHost = dispatchOperation.Parent.ChannelDispatcher.Host;

            if (!(serviceHost is WorkflowServiceHost))
            {
                throw FxTrace.Exception.AsError(
                          new InvalidOperationException(SR.WorkflowBehaviorWithNonWorkflowHost(typeof(ControlOperationBehavior).Name)));
            }

            ServiceEndpoint endpoint = null;

            foreach (ServiceEndpoint endpointToMatch in serviceHost.Description.Endpoints)
            {
                if (endpointToMatch.Id == dispatchOperation.Parent.EndpointDispatcher.Id)
                {
                    endpoint = endpointToMatch;
                    break;
                }
            }

            if (this.isWrappedMode)
            {
                CorrelationKeyCalculator keyCalculator = null;

                if (endpoint != null)
                {
                    CorrelationQueryBehavior endpointQueryBehavior = endpoint.Behaviors.Find <CorrelationQueryBehavior>();

                    if (endpointQueryBehavior != null)
                    {
                        keyCalculator = endpointQueryBehavior.GetKeyCalculator();
                    }
                }

                //This will be the case for infrastructure endpoints like Compensation/Interop OCS endpoints.
                dispatchOperation.Invoker = new ControlOperationInvoker(
                    operationDescription,
                    endpoint,
                    keyCalculator,
                    dispatchOperation.Invoker,
                    serviceHost);
            }
            else
            {
                //This will be for IWorkflowInstanceManagement endpoint operation.
                dispatchOperation.Invoker = new ControlOperationInvoker(
                    operationDescription,
                    endpoint,
                    null,
                    serviceHost);
            }
        }
Example #3
0
        public void ApplyDispatchBehavior(OperationDescription operationDescription, DispatchOperation dispatchOperation)
        {
            if (operationDescription == null)
            {
                throw System.ServiceModel.Activities.FxTrace.Exception.ArgumentNull("operationDescription");
            }
            if (dispatchOperation == null)
            {
                throw System.ServiceModel.Activities.FxTrace.Exception.ArgumentNull("dispatchOperation");
            }
            if (((dispatchOperation.Parent == null) || (dispatchOperation.Parent.ChannelDispatcher == null)) || (((dispatchOperation.Parent.ChannelDispatcher.Host == null) || (dispatchOperation.Parent.ChannelDispatcher.Host.Description == null)) || (dispatchOperation.Parent.ChannelDispatcher.Host.Description.Behaviors == null)))
            {
                throw System.ServiceModel.Activities.FxTrace.Exception.AsError(new InvalidOperationException(System.ServiceModel.Activities.SR.DispatchOperationInInvalidState));
            }
            ServiceHostBase host = dispatchOperation.Parent.ChannelDispatcher.Host;

            if (!(host is WorkflowServiceHost))
            {
                throw System.ServiceModel.Activities.FxTrace.Exception.AsError(new InvalidOperationException(System.ServiceModel.Activities.SR.WorkflowBehaviorWithNonWorkflowHost(typeof(WorkflowOperationBehavior).Name)));
            }
            CorrelationKeyCalculator keyCalculator = null;
            ServiceEndpoint          endpoint      = null;

            foreach (ServiceEndpoint endpoint2 in host.Description.Endpoints)
            {
                if (endpoint2.Id == dispatchOperation.Parent.EndpointDispatcher.Id)
                {
                    endpoint = endpoint2;
                    break;
                }
            }
            if (endpoint != null)
            {
                CorrelationQueryBehavior behavior = endpoint.Behaviors.Find <CorrelationQueryBehavior>();
                if (behavior != null)
                {
                    keyCalculator = behavior.GetKeyCalculator();
                }
            }
            dispatchOperation.Invoker = new WorkflowOperationInvoker(operationDescription, endpoint, keyCalculator, this, host, dispatchOperation.Invoker);
        }
Example #4
0
        public void ApplyDispatchBehavior(OperationDescription operationDescription, DispatchOperation dispatchOperation)
        {
            ServiceHostBase host = dispatchOperation.Parent.ChannelDispatcher.Host;

            if (!(host is WorkflowServiceHost))
            {
                throw FxTrace.Exception.AsError(new InvalidOperationException(System.ServiceModel.Activities.SR.WorkflowBehaviorWithNonWorkflowHost(typeof(ControlOperationBehavior).Name)));
            }
            ServiceEndpoint endpoint = null;

            foreach (ServiceEndpoint endpoint2 in host.Description.Endpoints)
            {
                if (endpoint2.Id == dispatchOperation.Parent.EndpointDispatcher.Id)
                {
                    endpoint = endpoint2;
                    break;
                }
            }
            if (this.isWrappedMode)
            {
                CorrelationKeyCalculator correlationKeyCalculator = null;
                if (endpoint != null)
                {
                    CorrelationQueryBehavior behavior = endpoint.Behaviors.Find <CorrelationQueryBehavior>();
                    if (behavior != null)
                    {
                        correlationKeyCalculator = behavior.GetKeyCalculator();
                    }
                }
                dispatchOperation.Invoker = new ControlOperationInvoker(operationDescription, endpoint, correlationKeyCalculator, dispatchOperation.Invoker, host);
            }
            else
            {
                dispatchOperation.Invoker = new ControlOperationInvoker(operationDescription, endpoint, null, host);
            }
        }