public void ApplyDispatchBehavior(ServiceDescription serviceDescription, ServiceHostBase serviceHostBase)
        {
            if (serviceDescription == null)
            {
                throw FxTrace.Exception.ArgumentNull("serviceDescription");
            }

            if (serviceHostBase == null)
            {
                throw FxTrace.Exception.ArgumentNull("serviceHostBase");
            }

            DurableInstanceContextProvider instanceContextProvider = new DurableInstanceContextProvider(serviceHostBase);
            DurableInstanceProvider instanceProvider = new DurableInstanceProvider(serviceHostBase);

            ServiceDebugBehavior serviceDebugBehavior = serviceDescription.Behaviors.Find<ServiceDebugBehavior>();

            bool includeExceptionDetailInFaults = serviceDebugBehavior != null ?
                serviceDebugBehavior.IncludeExceptionDetailInFaults
                : false;

            foreach (ChannelDispatcherBase channelDispatcherBase in serviceHostBase.ChannelDispatchers)
            {
                ChannelDispatcher channelDispatcher = channelDispatcherBase as ChannelDispatcher;

                if (channelDispatcher != null)
                {
                    foreach (EndpointDispatcher endPointDispatcher in channelDispatcher.Endpoints)
                    {
                        if (IsWorkflowEndpoint(endPointDispatcher))
                        {
                            DispatchRuntime dispatchRuntime = endPointDispatcher.DispatchRuntime;
                            dispatchRuntime.AutomaticInputSessionShutdown = true;
                            dispatchRuntime.ConcurrencyMode = ConcurrencyMode.Multiple;

                            //
                            dispatchRuntime.InstanceContextProvider = instanceContextProvider;
                            dispatchRuntime.InstanceProvider = instanceProvider;

                            if (includeExceptionDetailInFaults)
                            {
                                dispatchRuntime.SetDebugFlagInDispatchOperations(includeExceptionDetailInFaults);
                            }
                        }
                    }
                }
            }
        }
 public void ApplyDispatchBehavior(System.ServiceModel.Description.ServiceDescription serviceDescription, ServiceHostBase serviceHostBase)
 {
     if (serviceDescription == null)
     {
         throw System.ServiceModel.Activities.FxTrace.Exception.ArgumentNull("serviceDescription");
     }
     if (serviceHostBase == null)
     {
         throw System.ServiceModel.Activities.FxTrace.Exception.ArgumentNull("serviceHostBase");
     }
     DurableInstanceContextProvider provider = new DurableInstanceContextProvider(serviceHostBase);
     DurableInstanceProvider provider2 = new DurableInstanceProvider(serviceHostBase);
     ServiceDebugBehavior behavior = serviceDescription.Behaviors.Find<ServiceDebugBehavior>();
     bool includeExceptionDetailInFaults = (behavior != null) ? behavior.IncludeExceptionDetailInFaults : false;
     foreach (ChannelDispatcherBase base2 in serviceHostBase.ChannelDispatchers)
     {
         ChannelDispatcher dispatcher = base2 as ChannelDispatcher;
         if (dispatcher != null)
         {
             foreach (EndpointDispatcher dispatcher2 in dispatcher.Endpoints)
             {
                 if (IsWorkflowEndpoint(dispatcher2))
                 {
                     DispatchRuntime dispatchRuntime = dispatcher2.DispatchRuntime;
                     dispatchRuntime.AutomaticInputSessionShutdown = true;
                     dispatchRuntime.ConcurrencyMode = ConcurrencyMode.Multiple;
                     dispatchRuntime.InstanceContextProvider = provider;
                     dispatchRuntime.InstanceProvider = provider2;
                     if (includeExceptionDetailInFaults)
                     {
                         dispatchRuntime.SetDebugFlagInDispatchOperations(includeExceptionDetailInFaults);
                     }
                 }
             }
         }
     }
 }