public override CircuitHost CreateCircuitHost(HttpContext httpContext, IClientProxy client)
        {
            if (!_options.StartupActions.TryGetValue(httpContext.Request.Path, out var config))
            {
                var message = $"Could not find a Blazor startup action for request path {httpContext.Request.Path}";
                throw new InvalidOperationException(message);
            }

            var scope                  = _scopeFactory.CreateScope();
            var jsRuntime              = new RemoteJSRuntime(client);
            var rendererRegistry       = new RendererRegistry();
            var synchronizationContext = new CircuitSynchronizationContext();
            var renderer               = new RemoteRenderer(scope.ServiceProvider, rendererRegistry, jsRuntime, client, synchronizationContext);

            var circuitHost = new CircuitHost(
                scope,
                client,
                rendererRegistry,
                renderer,
                config,
                jsRuntime,
                synchronizationContext);

            // Initialize per-circuit data that services need
            (circuitHost.Services.GetRequiredService <IJSRuntimeAccessor>() as DefaultJSRuntimeAccessor).JSRuntime = jsRuntime;
            (circuitHost.Services.GetRequiredService <ICircuitAccessor>() as DefaultCircuitAccessor).Circuit       = circuitHost.Circuit;

            return(circuitHost);
        }
Example #2
0
        public static CircuitHost Create(
            string circuitId               = null,
            IServiceScope serviceScope     = null,
            RemoteRenderer remoteRenderer  = null,
            CircuitHandler[] handlers      = null,
            CircuitClientProxy clientProxy = null)
        {
            serviceScope = serviceScope ?? Mock.Of <IServiceScope>();
            clientProxy  = clientProxy ?? new CircuitClientProxy(Mock.Of <IClientProxy>(), Guid.NewGuid().ToString());
            var jsRuntime = new RemoteJSRuntime(Options.Create(new CircuitOptions()), Mock.Of <ILogger <RemoteJSRuntime> >());

            if (remoteRenderer == null)
            {
                remoteRenderer = new RemoteRenderer(
                    serviceScope.ServiceProvider ?? Mock.Of <IServiceProvider>(),
                    NullLoggerFactory.Instance,
                    new CircuitOptions(),
                    jsRuntime,
                    clientProxy,
                    HtmlEncoder.Default,
                    NullLogger.Instance);
            }

            handlers = handlers ?? Array.Empty <CircuitHandler>();
            return(new TestCircuitHost(
                       circuitId ?? Guid.NewGuid().ToString(),
                       serviceScope,
                       clientProxy,
                       remoteRenderer,
                       new List <ComponentDescriptor>(),
                       jsRuntime,
                       handlers,
                       NullLogger <CircuitHost> .Instance));
        }
Example #3
0
        public CircuitHost(
            string circuitId,
            IServiceScope scope,
            CircuitClientProxy client,
            RendererRegistry rendererRegistry,
            RemoteRenderer renderer,
            IList <ComponentDescriptor> descriptors,
            RemoteJSRuntime jsRuntime,
            CircuitHandler[] circuitHandlers,
            ILogger logger)
        {
            CircuitId        = circuitId;
            _scope           = scope ?? throw new ArgumentNullException(nameof(scope));
            Client           = client;
            RendererRegistry = rendererRegistry ?? throw new ArgumentNullException(nameof(rendererRegistry));
            Descriptors      = descriptors ?? throw new ArgumentNullException(nameof(descriptors));
            Renderer         = renderer ?? throw new ArgumentNullException(nameof(renderer));
            JSRuntime        = jsRuntime ?? throw new ArgumentNullException(nameof(jsRuntime));
            _logger          = logger;

            Services = scope.ServiceProvider;

            Circuit          = new Circuit(this);
            _circuitHandlers = circuitHandlers;

            Renderer.UnhandledException += Renderer_UnhandledException;
            Renderer.UnhandledSynchronizationException += SynchronizationContext_UnhandledException;
        }
Example #4
0
        public static CircuitHost Create(
            CircuitId?circuitId            = null,
            AsyncServiceScope?serviceScope = null,
            RemoteRenderer remoteRenderer  = null,
            CircuitHandler[] handlers      = null,
            CircuitClientProxy clientProxy = null)
        {
            serviceScope = serviceScope ?? new AsyncServiceScope(Mock.Of <IServiceScope>());
            clientProxy  = clientProxy ?? new CircuitClientProxy(Mock.Of <IClientProxy>(), Guid.NewGuid().ToString());
            var jsRuntime = new RemoteJSRuntime(Options.Create(new CircuitOptions()), Options.Create(new HubOptions()), Mock.Of <ILogger <RemoteJSRuntime> >());

            if (remoteRenderer == null)
            {
                remoteRenderer = new RemoteRenderer(
                    serviceScope.Value.ServiceProvider ?? Mock.Of <IServiceProvider>(),
                    NullLoggerFactory.Instance,
                    new CircuitOptions(),
                    clientProxy,
                    NullLogger.Instance,
                    null);
            }

            handlers ??= Array.Empty <CircuitHandler>();
            return(new TestCircuitHost(
                       circuitId is null ? new CircuitId(Guid.NewGuid().ToString(), Guid.NewGuid().ToString()) : circuitId.Value,
                       serviceScope.Value,
                       new CircuitOptions(),
                       clientProxy,
                       remoteRenderer,
                       new List <ComponentDescriptor>(),
                       jsRuntime,
                       handlers,
                       NullLogger <CircuitHost> .Instance));
        }
Example #5
0
        public CircuitHost CreateCircuitHost(
            IReadOnlyList <ComponentDescriptor> components,
            CircuitClientProxy client,
            string baseUri,
            string uri,
            ClaimsPrincipal user)
        {
            var scope     = _scopeFactory.CreateScope();
            var jsRuntime = (RemoteJSRuntime)scope.ServiceProvider.GetRequiredService <IJSRuntime>();

            jsRuntime.Initialize(client);

            var navigationManager      = (RemoteNavigationManager)scope.ServiceProvider.GetRequiredService <NavigationManager>();
            var navigationInterception = (RemoteNavigationInterception)scope.ServiceProvider.GetRequiredService <INavigationInterception>();

            if (client.Connected)
            {
                navigationManager.AttachJsRuntime(jsRuntime);
                navigationManager.Initialize(baseUri, uri);

                navigationInterception.AttachJSRuntime(jsRuntime);
            }
            else
            {
                navigationManager.Initialize(baseUri, uri);
            }

            var renderer = new RemoteRenderer(
                scope.ServiceProvider,
                _loggerFactory,
                _options,
                client,
                _loggerFactory.CreateLogger <RemoteRenderer>(),
                jsRuntime.ElementReferenceContext);

            var circuitHandlers = scope.ServiceProvider.GetServices <CircuitHandler>()
                                  .OrderBy(h => h.Order)
                                  .ToArray();

            var circuitHost = new CircuitHost(
                _circuitIdFactory.CreateCircuitId(),
                scope,
                _options,
                client,
                renderer,
                components,
                jsRuntime,
                circuitHandlers,
                _loggerFactory.CreateLogger <CircuitHost>());

            Log.CreatedCircuit(_logger, circuitHost);

            // Initialize per - circuit data that services need
            (circuitHost.Services.GetRequiredService <ICircuitAccessor>() as DefaultCircuitAccessor).Circuit = circuitHost.Circuit;
            circuitHost.SetCircuitUser(user);

            return(circuitHost);
        }
        public override CircuitHost CreateCircuitHost(
            HttpContext httpContext,
            CircuitClientProxy client,
            string uriAbsolute,
            string baseUriAbsolute)
        {
            var components = ResolveComponentMetadata(httpContext, client);

            var scope            = _scopeFactory.CreateScope();
            var encoder          = scope.ServiceProvider.GetRequiredService <HtmlEncoder>();
            var jsRuntime        = (RemoteJSRuntime)scope.ServiceProvider.GetRequiredService <IJSRuntime>();
            var componentContext = (RemoteComponentContext)scope.ServiceProvider.GetRequiredService <IComponentContext>();

            jsRuntime.Initialize(client);
            componentContext.Initialize(client);

            var uriHelper = (RemoteUriHelper)scope.ServiceProvider.GetRequiredService <IUriHelper>();

            if (client != CircuitClientProxy.OfflineClient)
            {
                uriHelper.Initialize(uriAbsolute, baseUriAbsolute, jsRuntime);
            }
            else
            {
                uriHelper.Initialize(uriAbsolute, baseUriAbsolute);
            }

            var rendererRegistry = new RendererRegistry();
            var dispatcher       = Renderer.CreateDefaultDispatcher();
            var renderer         = new RemoteRenderer(
                scope.ServiceProvider,
                rendererRegistry,
                jsRuntime,
                client,
                dispatcher,
                encoder,
                _loggerFactory.CreateLogger <RemoteRenderer>());

            var circuitHandlers = scope.ServiceProvider.GetServices <CircuitHandler>()
                                  .OrderBy(h => h.Order)
                                  .ToArray();

            var circuitHost = new CircuitHost(
                scope,
                client,
                rendererRegistry,
                renderer,
                components,
                dispatcher,
                jsRuntime,
                circuitHandlers,
                _loggerFactory.CreateLogger <CircuitHost>());

            // Initialize per - circuit data that services need
            (circuitHost.Services.GetRequiredService <ICircuitAccessor>() as DefaultCircuitAccessor).Circuit = circuitHost.Circuit;

            return(circuitHost);
        }
Example #7
0
        public CircuitHost(
            CircuitId circuitId,
            AsyncServiceScope scope,
            CircuitOptions options,
            CircuitClientProxy client,
            RemoteRenderer renderer,
            IReadOnlyList <ComponentDescriptor> descriptors,
            RemoteJSRuntime jsRuntime,
            CircuitHandler[] circuitHandlers,
            ILogger logger)
        {
            CircuitId = circuitId;
            if (CircuitId.Secret is null)
            {
                // Prevent the use of a 'default' secret.
                throw new ArgumentException($"Property '{nameof(CircuitId.Secret)}' cannot be null.", nameof(circuitId));
            }

            _scope           = scope;
            _options         = options ?? throw new ArgumentNullException(nameof(options));
            Client           = client ?? throw new ArgumentNullException(nameof(client));
            Renderer         = renderer ?? throw new ArgumentNullException(nameof(renderer));
            Descriptors      = descriptors ?? throw new ArgumentNullException(nameof(descriptors));
            JSRuntime        = jsRuntime ?? throw new ArgumentNullException(nameof(jsRuntime));
            _circuitHandlers = circuitHandlers ?? throw new ArgumentNullException(nameof(circuitHandlers));
            _logger          = logger ?? throw new ArgumentNullException(nameof(logger));

            Services = scope.ServiceProvider;

            Circuit = new Circuit(this);
            Handle  = new CircuitHandle()
            {
                CircuitHost = this,
            };

            // An unhandled exception from the renderer is always fatal because it came from user code.
            Renderer.UnhandledException += ReportAndInvoke_UnhandledException;
            Renderer.UnhandledSynchronizationException += SynchronizationContext_UnhandledException;

            JSRuntime.UnhandledException += ReportAndInvoke_UnhandledException;
        }
        public override CircuitHost CreateCircuitHost(HttpContext httpContext, IClientProxy client)
        {
            if (!_options.StartupActions.TryGetValue(httpContext.Request.Path, out var config))
            {
                var message = $"Could not find an ASP.NET Core Components startup action for request path '{httpContext.Request.Path}'.";
                throw new InvalidOperationException(message);
            }

            var scope            = _scopeFactory.CreateScope();
            var jsRuntime        = new RemoteJSRuntime(client);
            var rendererRegistry = new RendererRegistry();
            var dispatcher       = Renderer.CreateDefaultDispatcher();
            var renderer         = new RemoteRenderer(
                scope.ServiceProvider,
                rendererRegistry,
                jsRuntime,
                client,
                dispatcher,
                _loggerFactory.CreateLogger <RemoteRenderer>());

            var circuitHandlers = scope.ServiceProvider.GetServices <CircuitHandler>()
                                  .OrderBy(h => h.Order)
                                  .ToArray();

            var circuitHost = new CircuitHost(
                scope,
                client,
                rendererRegistry,
                renderer,
                config,
                jsRuntime,
                circuitHandlers);

            // Initialize per-circuit data that services need
            (circuitHost.Services.GetRequiredService <IJSRuntimeAccessor>() as DefaultJSRuntimeAccessor).JSRuntime = jsRuntime;
            (circuitHost.Services.GetRequiredService <ICircuitAccessor>() as DefaultCircuitAccessor).Circuit       = circuitHost.Circuit;

            return(circuitHost);
        }
Example #9
0
        private static CircuitHost GetCircuitHost(
            IServiceScope serviceScope    = null,
            RemoteRenderer remoteRenderer = null,
            CircuitHandler[] handlers     = null)
        {
            serviceScope = serviceScope ?? Mock.Of <IServiceScope>();
            var clientProxy    = Mock.Of <IClientProxy>();
            var renderRegistry = new RendererRegistry();
            var jsRuntime      = Mock.Of <IJSRuntime>();

            remoteRenderer = remoteRenderer ?? GetRemoteRenderer();
            handlers       = handlers ?? Array.Empty <CircuitHandler>();

            return(new CircuitHost(
                       serviceScope,
                       clientProxy,
                       renderRegistry,
                       remoteRenderer,
                       configure: _ => { },
                       jsRuntime: jsRuntime,
                       handlers));
        }
Example #10
0
        public CircuitHost(
            CircuitId circuitId,
            IServiceScope scope,
            CircuitOptions options,
            CircuitClientProxy client,
            RemoteRenderer renderer,
            IReadOnlyList <ComponentDescriptor> descriptors,
            RemoteJSRuntime jsRuntime,
            CircuitHandler[] circuitHandlers,
            ILogger logger)
        {
            CircuitId = circuitId;
            if (CircuitId.Secret is null)
            {
                // Prevent the use of a 'default' secret.
                throw new ArgumentException(nameof(circuitId));
            }

            _scope           = scope ?? throw new ArgumentNullException(nameof(scope));
            _options         = options ?? throw new ArgumentNullException(nameof(options));
            Client           = client ?? throw new ArgumentNullException(nameof(client));
            Renderer         = renderer ?? throw new ArgumentNullException(nameof(renderer));
            Descriptors      = descriptors ?? throw new ArgumentNullException(nameof(descriptors));
            JSRuntime        = jsRuntime ?? throw new ArgumentNullException(nameof(jsRuntime));
            _circuitHandlers = circuitHandlers ?? throw new ArgumentNullException(nameof(circuitHandlers));
            _logger          = logger ?? throw new ArgumentNullException(nameof(logger));

            Services = scope.ServiceProvider;

            Circuit = new Circuit(this);
            Handle  = new CircuitHandle()
            {
                CircuitHost = this,
            };

            Renderer.UnhandledException += Renderer_UnhandledException;
            Renderer.UnhandledSynchronizationException += SynchronizationContext_UnhandledException;
        }
Example #11
0
        public static CircuitHost Create(
            IServiceScope serviceScope     = null,
            RemoteRenderer remoteRenderer  = null,
            CircuitHandler[] handlers      = null,
            CircuitClientProxy clientProxy = null)
        {
            serviceScope = serviceScope ?? Mock.Of <IServiceScope>();
            clientProxy  = clientProxy ?? new CircuitClientProxy(Mock.Of <IClientProxy>(), Guid.NewGuid().ToString());
            var renderRegistry = new RendererRegistry();
            var jsRuntime      = new RemoteJSRuntime();
            var dispatcher     = Rendering.Renderer.CreateDefaultDispatcher();

            if (remoteRenderer == null)
            {
                remoteRenderer = new RemoteRenderer(
                    Mock.Of <IServiceProvider>(),
                    new RendererRegistry(),
                    jsRuntime,
                    clientProxy,
                    dispatcher,
                    HtmlEncoder.Default,
                    NullLogger.Instance);
            }

            handlers = handlers ?? Array.Empty <CircuitHandler>();
            return(new TestCircuitHost(
                       serviceScope,
                       clientProxy,
                       renderRegistry,
                       remoteRenderer,
                       new List <ComponentDescriptor>(),
                       dispatcher,
                       jsRuntime,
                       handlers,
                       NullLogger <CircuitHost> .Instance));
        }
Example #12
0
        private static CircuitHost GetCircuitHost(
            IServiceScope serviceScope    = null,
            RemoteRenderer remoteRenderer = null,
            CircuitHandler[] handlers     = null)
        {
            serviceScope = serviceScope ?? Mock.Of <IServiceScope>();
            var clientProxy    = Mock.Of <IClientProxy>();
            var renderRegistry = new RendererRegistry();
            var jsRuntime      = Mock.Of <IJSRuntime>();
            var dispatcher     = Renderer.CreateDefaultDispatcher();

            remoteRenderer = remoteRenderer ?? GetRemoteRenderer(dispatcher);
            handlers       = handlers ?? Array.Empty <CircuitHandler>();

            return(new CircuitHost(
                       serviceScope,
                       clientProxy,
                       renderRegistry,
                       remoteRenderer,
                       new List <ComponentDescriptor>(),
                       dispatcher,
                       jsRuntime: jsRuntime,
                       handlers));
        }
Example #13
0
        public CircuitHost(
            IServiceScope scope,
            IClientProxy client,
            RendererRegistry rendererRegistry,
            RemoteRenderer renderer,
            Action <IBlazorApplicationBuilder> configure,
            IJSRuntime jsRuntime,
            CircuitSynchronizationContext synchronizationContext)
        {
            Scope                  = scope ?? throw new ArgumentNullException(nameof(scope));
            Client                 = client ?? throw new ArgumentNullException(nameof(client));
            RendererRegistry       = rendererRegistry ?? throw new ArgumentNullException(nameof(rendererRegistry));
            Renderer               = renderer ?? throw new ArgumentNullException(nameof(renderer));
            _configure             = configure ?? throw new ArgumentNullException(nameof(configure));
            JSRuntime              = jsRuntime ?? throw new ArgumentNullException(nameof(jsRuntime));
            SynchronizationContext = synchronizationContext ?? throw new ArgumentNullException(nameof(synchronizationContext));

            Services = scope.ServiceProvider;

            Circuit = new Circuit(this);

            Renderer.UnhandledException += Renderer_UnhandledException;
            SynchronizationContext.UnhandledException += SynchronizationContext_UnhandledException;
        }
Example #14
0
 private TestCircuitHost(string circuitId, IServiceScope scope, CircuitClientProxy client, RendererRegistry rendererRegistry, RemoteRenderer renderer, IReadOnlyList <ComponentDescriptor> descriptors, RemoteJSRuntime jsRuntime, CircuitHandler[] circuitHandlers, ILogger logger)
     : base(circuitId, scope, client, rendererRegistry, renderer, descriptors, jsRuntime, circuitHandlers, logger)
 {
 }
Example #15
0
        public override CircuitHost CreateCircuitHost(
            HttpContext httpContext,
            CircuitClientProxy client,
            string uriAbsolute,
            string baseUriAbsolute,
            ClaimsPrincipal user)
        {
            var components = ResolveComponentMetadata(httpContext, client);

            var scope            = _scopeFactory.CreateScope();
            var encoder          = scope.ServiceProvider.GetRequiredService <HtmlEncoder>();
            var jsRuntime        = (RemoteJSRuntime)scope.ServiceProvider.GetRequiredService <IJSRuntime>();
            var componentContext = (RemoteComponentContext)scope.ServiceProvider.GetRequiredService <IComponentContext>();

            jsRuntime.Initialize(client);
            componentContext.Initialize(client);

            var uriHelper = (RemoteUriHelper)scope.ServiceProvider.GetRequiredService <IUriHelper>();
            var navigationInterception = (RemoteNavigationInterception)scope.ServiceProvider.GetRequiredService <INavigationInterception>();

            if (client.Connected)
            {
                uriHelper.AttachJsRuntime(jsRuntime);
                uriHelper.InitializeState(
                    uriAbsolute,
                    baseUriAbsolute);

                navigationInterception.AttachJSRuntime(jsRuntime);
            }
            else
            {
                uriHelper.InitializeState(uriAbsolute, baseUriAbsolute);
            }

            var rendererRegistry = new RendererRegistry();
            var renderer         = new RemoteRenderer(
                scope.ServiceProvider,
                _loggerFactory,
                rendererRegistry,
                jsRuntime,
                client,
                encoder,
                _loggerFactory.CreateLogger <RemoteRenderer>());

            var circuitHandlers = scope.ServiceProvider.GetServices <CircuitHandler>()
                                  .OrderBy(h => h.Order)
                                  .ToArray();

            var circuitHost = new CircuitHost(
                _circuitIdFactory.CreateCircuitId(),
                scope,
                client,
                rendererRegistry,
                renderer,
                components,
                jsRuntime,
                circuitHandlers,
                _loggerFactory.CreateLogger <CircuitHost>());

            Log.CreatedCircuit(_logger, circuitHost);

            // Initialize per - circuit data that services need
            (circuitHost.Services.GetRequiredService <ICircuitAccessor>() as DefaultCircuitAccessor).Circuit = circuitHost.Circuit;
            circuitHost.SetCircuitUser(user);

            return(circuitHost);
        }
Example #16
0
        public override CircuitHost CreateCircuitHost(
            HttpContext httpContext,
            CircuitClientProxy client,
            string uriAbsolute,
            string baseUriAbsolute)
        {
            var components = ResolveComponentMetadata(httpContext, client);

            var scope            = _scopeFactory.CreateScope();
            var encoder          = scope.ServiceProvider.GetRequiredService <HtmlEncoder>();
            var jsRuntime        = (RemoteJSRuntime)scope.ServiceProvider.GetRequiredService <IJSRuntime>();
            var componentContext = (RemoteComponentContext)scope.ServiceProvider.GetRequiredService <IComponentContext>();

            jsRuntime.Initialize(client);
            componentContext.Initialize(client);

            // You can replace the AuthenticationStateProvider with a custom one, but in that case initialization is up to you
            var authenticationStateProvider = scope.ServiceProvider.GetService <AuthenticationStateProvider>();

            (authenticationStateProvider as FixedAuthenticationStateProvider)?.Initialize(httpContext.User);

            var uriHelper = (RemoteUriHelper)scope.ServiceProvider.GetRequiredService <IUriHelper>();

            if (client.Connected)
            {
                uriHelper.AttachJsRuntime(jsRuntime);
                uriHelper.InitializeState(
                    uriAbsolute,
                    baseUriAbsolute);
            }
            else
            {
                uriHelper.InitializeState(uriAbsolute, baseUriAbsolute);
            }

            var rendererRegistry = new RendererRegistry();
            var dispatcher       = Renderer.CreateDefaultDispatcher();
            var renderer         = new RemoteRenderer(
                scope.ServiceProvider,
                rendererRegistry,
                jsRuntime,
                client,
                dispatcher,
                encoder,
                _loggerFactory.CreateLogger <RemoteRenderer>());

            var circuitHandlers = scope.ServiceProvider.GetServices <CircuitHandler>()
                                  .OrderBy(h => h.Order)
                                  .ToArray();

            var circuitHost = new CircuitHost(
                scope,
                client,
                rendererRegistry,
                renderer,
                components,
                dispatcher,
                jsRuntime,
                circuitHandlers,
                _loggerFactory.CreateLogger <CircuitHost>());

            // Initialize per - circuit data that services need
            (circuitHost.Services.GetRequiredService <ICircuitAccessor>() as DefaultCircuitAccessor).Circuit = circuitHost.Circuit;

            return(circuitHost);
        }
        public override CircuitHost CreateCircuitHost(
            HttpContext httpContext,
            CircuitClientProxy client,
            string baseUri,
            string uri,
            ClaimsPrincipal user)
        {
            // We do as much intialization as possible eagerly in this method, which makes the error handling
            // story much simpler. If we throw from here, it's handled inside the initial hub method.
            var components = ResolveComponentMetadata(httpContext, client);

            var scope            = _scopeFactory.CreateScope();
            var encoder          = scope.ServiceProvider.GetRequiredService <HtmlEncoder>();
            var jsRuntime        = (RemoteJSRuntime)scope.ServiceProvider.GetRequiredService <IJSRuntime>();
            var componentContext = (RemoteComponentContext)scope.ServiceProvider.GetRequiredService <IComponentContext>();

            jsRuntime.Initialize(client);
            componentContext.Initialize(client);

            var navigationManager      = (RemoteNavigationManager)scope.ServiceProvider.GetRequiredService <NavigationManager>();
            var navigationInterception = (RemoteNavigationInterception)scope.ServiceProvider.GetRequiredService <INavigationInterception>();

            if (client.Connected)
            {
                navigationManager.AttachJsRuntime(jsRuntime);
                navigationManager.Initialize(baseUri, uri);

                navigationInterception.AttachJSRuntime(jsRuntime);
            }
            else
            {
                navigationManager.Initialize(baseUri, uri);
            }

            var renderer = new RemoteRenderer(
                scope.ServiceProvider,
                _loggerFactory,
                _options,
                jsRuntime,
                client,
                encoder,
                _loggerFactory.CreateLogger <RemoteRenderer>());

            var circuitHandlers = scope.ServiceProvider.GetServices <CircuitHandler>()
                                  .OrderBy(h => h.Order)
                                  .ToArray();

            var circuitHost = new CircuitHost(
                _circuitIdFactory.CreateCircuitId(),
                scope,
                client,
                renderer,
                components,
                jsRuntime,
                circuitHandlers,
                _loggerFactory.CreateLogger <CircuitHost>());

            Log.CreatedCircuit(_logger, circuitHost);

            // Initialize per - circuit data that services need
            (circuitHost.Services.GetRequiredService <ICircuitAccessor>() as DefaultCircuitAccessor).Circuit = circuitHost.Circuit;
            circuitHost.SetCircuitUser(user);

            return(circuitHost);
        }
Example #18
0
 private TestCircuitHost(CircuitId circuitId, AsyncServiceScope scope, CircuitOptions options, CircuitClientProxy client, RemoteRenderer renderer, IReadOnlyList <ComponentDescriptor> descriptors, RemoteJSRuntime jsRuntime, CircuitHandler[] circuitHandlers, ILogger logger)
     : base(circuitId, scope, options, client, renderer, descriptors, jsRuntime, circuitHandlers, logger)
 {
 }
Example #19
0
 private TestCircuitHost(IServiceScope scope, CircuitClientProxy client, RendererRegistry rendererRegistry, RemoteRenderer renderer, IList <ComponentDescriptor> descriptors, IDispatcher dispatcher, RemoteJSRuntime jsRuntime, CircuitHandler[] circuitHandlers, ILogger logger)
     : base(scope, client, rendererRegistry, renderer, descriptors, dispatcher, jsRuntime, circuitHandlers, logger)
 {
 }