public void InitializeBindings()

in src/DurableWorker/DurableController.cs [88:124]


        public void InitializeBindings(IList<ParameterBinding> inputData, out bool hasExternalSDK)
        {
            this.tryEnablingExternalSDK();

            // If the function is an durable client, then we set the DurableClient
            // in the module context for the 'Start-DurableOrchestration' function to use.
            if (_durableFunctionInfo.IsDurableClient)
            {
                var durableClient =
                    inputData.First(item => item.Name == _durableFunctionInfo.DurableClientBindingName)
                        .Data.ToObject(isDurableClient: true);

                _powerShellServices.SetDurableClient(durableClient);
            }
            else if (_durableFunctionInfo.IsOrchestrationFunction)
            {
                var numBindings = inputData.Count;
                if (numBindings != 1)
                {
                    /* Quote from https://docs.microsoft.com/en-us/azure/azure-functions/durable-functions-bindings:
                     *
                     * "Orchestrator functions should never use any input or output bindings other than the orchestration trigger binding.
                     *  Doing so has the potential to cause problems with the Durable Task extension because those bindings may not obey the single-threading and I/O rules."
                     *
                     * Therefore, it's by design that input data contains only one item, which is the metadata of the orchestration context.
                     */
                    var exceptionMessage = string.Format(PowerShellWorkerStrings.UnableToInitializeOrchestrator, numBindings);
                    throw new ArgumentException(exceptionMessage);
                }

                _orchestrationBindingInfo = _powerShellServices.SetOrchestrationContext(
                    inputData[0],
                    out IExternalOrchestrationInvoker externalInvoker);
                _orchestrationInvoker.SetExternalInvoker(externalInvoker);
            }
            hasExternalSDK = _powerShellServices.HasExternalDurableSDK();
        }