static void SetDiscoveryImplementation(EndpointDispatcher endpointDispatcher, DiscoveryService discoveryService) { DispatchRuntime dispatchRuntime = endpointDispatcher.DispatchRuntime; dispatchRuntime.SynchronizationContext = null; dispatchRuntime.ConcurrencyMode = ConcurrencyMode.Multiple; ServiceDiscoveryInstanceContextProvider provider = new ServiceDiscoveryInstanceContextProvider(discoveryService); dispatchRuntime.InstanceContextProvider = provider; dispatchRuntime.InstanceProvider = provider; dispatchRuntime.Type = discoveryService.GetType(); }