public ControlOperationInvoker(OperationDescription description, ServiceEndpoint endpoint, CorrelationKeyCalculator correlationKeyCalculator, IOperationInvoker innerInvoker, ServiceHostBase host)
        {
            this.host            = (WorkflowServiceHost)host;
            this.instanceManager = this.host.DurableInstanceManager;
            this.operationName   = description.Name;
            this.isOneWay        = description.IsOneWay;
            this.endpoint        = endpoint;
            this.innerInvoker    = innerInvoker;
            this.keyCalculator   = correlationKeyCalculator;
            this.persistTimeout  = this.host.PersistTimeout;
            if (description.DeclaringContract == WorkflowControlEndpoint.WorkflowControlServiceContract)
            {
                this.isControlOperation = true;
                switch (this.operationName)
                {
                case "Cancel":
                case "TransactedCancel":
                case "Run":
                case "TransactedRun":
                case "Unsuspend":
                case "TransactedUnsuspend":
                    this.inputParameterCount = 1;
                    return;

                case "Abandon":
                case "Suspend":
                case "TransactedSuspend":
                case "Terminate":
                case "TransactedTerminate":
                    this.inputParameterCount = 2;
                    return;
                }
                throw Fx.AssertAndThrow("Unreachable code");
            }
            if (endpoint is WorkflowHostingEndpoint)
            {
                this.CanCreateInstance = true;
            }
            else
            {
                this.bufferedReceiveManager = this.host.Extensions.Find <System.ServiceModel.Activities.Dispatcher.BufferedReceiveManager>();
            }
        }
        public ControlOperationInvoker(OperationDescription description, ServiceEndpoint endpoint, CorrelationKeyCalculator correlationKeyCalculator, IOperationInvoker innerInvoker, ServiceHostBase host)
        {
            this.host = (WorkflowServiceHost) host;
            this.instanceManager = this.host.DurableInstanceManager;
            this.operationName = description.Name;
            this.isOneWay = description.IsOneWay;
            this.endpoint = endpoint;
            this.innerInvoker = innerInvoker;
            this.keyCalculator = correlationKeyCalculator;
            this.persistTimeout = this.host.PersistTimeout;
            if (description.DeclaringContract == WorkflowControlEndpoint.WorkflowControlServiceContract)
            {
                this.isControlOperation = true;
                switch (this.operationName)
                {
                    case "Cancel":
                    case "TransactedCancel":
                    case "Run":
                    case "TransactedRun":
                    case "Unsuspend":
                    case "TransactedUnsuspend":
                        this.inputParameterCount = 1;
                        return;

                    case "Abandon":
                    case "Suspend":
                    case "TransactedSuspend":
                    case "Terminate":
                    case "TransactedTerminate":
                        this.inputParameterCount = 2;
                        return;
                }
                throw Fx.AssertAndThrow("Unreachable code");
            }
            if (endpoint is WorkflowHostingEndpoint)
            {
                this.CanCreateInstance = true;
            }
            else
            {
                this.bufferedReceiveManager = this.host.Extensions.Find<System.ServiceModel.Activities.Dispatcher.BufferedReceiveManager>();
            }
        }
 private WorkflowServiceInstance(Activity workflowDefinition, Guid instanceId, WorkflowServiceHost serviceHost, PersistenceContext persistenceContext) : base(workflowDefinition)
 {
     this.serviceHost = serviceHost;
     this.instanceId = instanceId;
     this.persistTimeout = serviceHost.PersistTimeout;
     this.trackTimeout = serviceHost.TrackTimeout;
     this.bufferedReceiveManager = serviceHost.Extensions.Find<System.ServiceModel.Activities.Dispatcher.BufferedReceiveManager>();
     if (persistenceContext != null)
     {
         this.persistenceContext = persistenceContext;
         this.persistenceContext.Closed += new EventHandler(this.OnPersistenceContextClosed);
     }
     this.thisLock = new object();
     this.pendingRequests = new List<WorkflowOperationContext>();
     this.executorLock = new WorkflowExecutionLock(this);
     this.activeOperationsLock = new object();
     this.acquireReferenceSemaphore = new ThreadNeutralSemaphore(1);
     this.acquireLockTimeout = TimeSpan.MaxValue;
     this.referenceCount = 1;
     this.TryAddReference();
 }