示例#1
0
        private CircuitHost GetOrCreateCircuitHost(HttpContext context, CircuitNavigationStatus navigationStatus)
        {
            if (context.Items.TryGetValue(CircuitHostKey, out var existingHost))
            {
                return((CircuitHost)existingHost);
            }
            else
            {
                var result = _circuitFactory.CreateCircuitHost(
                    context,
                    client: new CircuitClientProxy(), // This creates an "offline" client.
                    GetFullUri(context.Request),
                    GetFullBaseUri(context.Request));

                result.UnhandledException += CircuitHost_UnhandledException;
                context.Response.OnCompleted(() =>
                {
                    result.UnhandledException -= CircuitHost_UnhandledException;
                    if (!navigationStatus.Navigated)
                    {
                        _registry.RegisterDisconnectedCircuit(result);
                    }

                    return(Task.CompletedTask);
                });
                context.Items.Add(CircuitHostKey, result);

                return(result);
            }
        }
示例#2
0
 private CircuitNavigationStatus GetOrCreateNavigationStatus(HttpContext context)
 {
     if (context.Items.TryGetValue(NavigationStatusKey, out var existingHost))
     {
         return((CircuitNavigationStatus)existingHost);
     }
     else
     {
         var navigationStatus = new CircuitNavigationStatus();
         context.Items[NavigationStatusKey] = navigationStatus;
         return(navigationStatus);
     }
 }
示例#3
0
 private static async Task CleanupCircuitState(HttpContext context, CircuitNavigationStatus navigationStatus, CircuitHost circuitHost)
 {
     navigationStatus.Navigated = true;
     context.Items.Remove(CircuitHostKey);
     await circuitHost.DisposeAsync();
 }