コード例 #1
0
ファイル: CircuitHost.cs プロジェクト: xs-sun/AspNetCore
        public CircuitHost(
            IServiceScope scope,
            CircuitClientProxy client,
            RendererRegistry rendererRegistry,
            RemoteRenderer renderer,
            IList <ComponentDescriptor> descriptors,
            IDispatcher dispatcher,
            RemoteJSRuntime jsRuntime,
            CircuitHandler[] circuitHandlers,
            ILogger logger)
        {
            _scope           = scope ?? throw new ArgumentNullException(nameof(scope));
            Dispatcher       = dispatcher;
            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;
        }
コード例 #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));
        }
コード例 #3
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));
        }
コード例 #4
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);

            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);
        }
コード例 #5
0
ファイル: CircuitFactory.cs プロジェクト: zzl1010/aspnetcore
        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);
        }
コード例 #6
0
 /// <summary>
 /// Creates a new <see cref="RemoteRenderer"/>.
 /// </summary>
 public RemoteRenderer(
     IServiceProvider serviceProvider,
     ILoggerFactory loggerFactory,
     CircuitOptions options,
     CircuitClientProxy client,
     ILogger logger)
     : base(serviceProvider, loggerFactory)
 {
     _client  = client;
     _options = options;
     _logger  = logger;
 }
コード例 #7
0
        /// <summary>
        /// Creates a new <see cref="RemoteRenderer"/>.
        /// </summary>
        public RemoteRenderer(
            IServiceProvider serviceProvider,
            ILoggerFactory loggerFactory,
            CircuitOptions options,
            CircuitClientProxy client,
            ILogger logger,
            ElementReferenceContext?elementReferenceContext)
            : base(serviceProvider, loggerFactory)
        {
            _client  = client;
            _options = options;
            _logger  = logger;

            ElementReferenceContext = elementReferenceContext;
        }
コード例 #8
0
        public void Transfer_SetsConnected()
        {
            // Arrange
            var clientProxy = Mock.Of <IClientProxy>(
                c => c.SendCoreAsync(It.IsAny <string>(), It.IsAny <object[]>(), It.IsAny <CancellationToken>()) == Task.CompletedTask);
            var circuitClient = new CircuitClientProxy(clientProxy, "connection0");

            circuitClient.SetDisconnected();

            // Act
            circuitClient.Transfer(Mock.Of <IClientProxy>(), "connection1");

            // Assert
            Assert.True(circuitClient.Connected);
        }
コード例 #9
0
        /// <summary>
        /// Creates a new <see cref="RemoteRenderer"/>.
        /// </summary>
        public RemoteRenderer(
            IServiceProvider serviceProvider,
            ILoggerFactory loggerFactory,
            CircuitOptions options,
            CircuitClientProxy client,
            ILogger logger,
            RemoteJSRuntime jsRuntime,
            CircuitJSComponentInterop jsComponentInterop)
            : base(serviceProvider, loggerFactory, jsRuntime.ReadJsonSerializerOptions(), jsComponentInterop)
        {
            _client  = client;
            _options = options;
            _logger  = logger;

            ElementReferenceContext = jsRuntime.ElementReferenceContext;
        }
コード例 #10
0
ファイル: CircuitHost.cs プロジェクト: ilkayilknur/aspnetcore
        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;
        }
コード例 #11
0
        public async Task SendCoreAsync_WithoutTransfer()
        {
            // Arrange
            bool?isCancelled = null;
            var  clientProxy = new Mock <IClientProxy>();

            clientProxy.Setup(c => c.SendCoreAsync(It.IsAny <string>(), It.IsAny <object[]>(), It.IsAny <CancellationToken>()))
            .Callback((string _, object[] __, CancellationToken token) =>
            {
                isCancelled = token.IsCancellationRequested;
            })
            .Returns(Task.CompletedTask);
            var circuitClient = new CircuitClientProxy(clientProxy.Object, "connection0");

            // Act
            var   sendTask = circuitClient.SendCoreAsync("test", Array.Empty <object>());
            await sendTask;

            // Assert
            Assert.False(isCancelled);
        }
コード例 #12
0
ファイル: CircuitHost.cs プロジェクト: omajid/AspNetCore
        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;
        }
コード例 #13
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));
        }
コード例 #14
0
ファイル: TestCircuitHost.cs プロジェクト: zjklee/AspNetCore
 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)
 {
 }
コード例 #15
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)
 {
 }
コード例 #16
0
        private static IList <ComponentDescriptor> ResolveComponentMetadata(HttpContext httpContext, CircuitClientProxy client)
        {
            if (client == CircuitClientProxy.OfflineClient)
            {
                // This is the prerendering case.
                return(Array.Empty <ComponentDescriptor>());
            }
            else
            {
                var endpointFeature = httpContext.Features.Get <IEndpointFeature>();
                var endpoint        = endpointFeature?.Endpoint;
                if (endpoint == null)
                {
                    throw new InvalidOperationException(
                              $"{nameof(ComponentHub)} doesn't have an associated endpoint. " +
                              "Use 'app.UseRouting(routes => routes.MapComponentHub<App>(\"app\"))' to register your hub.");
                }

                var componentsMetadata = endpoint.Metadata.OfType <ComponentDescriptor>().ToList();
                if (componentsMetadata.Count == 0)
                {
                    throw new InvalidOperationException("No component was registered with the component hub.");
                }

                return(componentsMetadata);
            }
        }
コード例 #17
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);
        }
コード例 #18
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);
        }
コード例 #19
0
        internal static IList <ComponentDescriptor> ResolveComponentMetadata(HttpContext httpContext, CircuitClientProxy client)
        {
            if (!client.Connected)
            {
                // This is the prerendering case. Descriptors will be registered by the prerenderer.
                return(new List <ComponentDescriptor>());
            }
            else
            {
                var endpointFeature = httpContext.Features.Get <IEndpointFeature>();
                var endpoint        = endpointFeature?.Endpoint;
                if (endpoint == null)
                {
                    throw new InvalidOperationException(
                              $"{nameof(ComponentHub)} doesn't have an associated endpoint. " +
                              "Use 'app.UseEndpoints(endpoints => endpoints.MapBlazorHub<App>(\"app\"))' to register your hub.");
                }

                var componentsMetadata = endpoint.Metadata.OfType <ComponentDescriptor>().ToList();

                return(componentsMetadata);
            }
        }
コード例 #20
0
 internal void Initialize(CircuitClientProxy clientProxy)
 {
     _clientProxy = clientProxy ?? throw new ArgumentNullException(nameof(clientProxy));
 }
コード例 #21
0
        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);
        }
コード例 #22
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)
 {
 }
コード例 #23
0
ファイル: CircuitFactory.cs プロジェクト: Higourang/AspNetCor
 public abstract CircuitHost CreateCircuitHost(
     HttpContext httpContext,
     CircuitClientProxy client,
     string baseUri,
     string uri,
     ClaimsPrincipal user);
コード例 #24
0
 public abstract CircuitHost CreateCircuitHost(
     HttpContext httpContext,
     CircuitClientProxy client,
     string uriAbsolute,
     string baseUriAbsolute);