Exemple #1
0
        public CircuitHost(
            string circuitId,
            IServiceScope scope,
            CircuitOptions options,
            CircuitClientProxy client,
            RemoteRenderer renderer,
            IReadOnlyList <ComponentDescriptor> descriptors,
            RemoteJSRuntime jsRuntime,
            CircuitHandler[] circuitHandlers,
            ILogger logger)
        {
            CircuitId = circuitId ?? throw new ArgumentNullException(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;
        }
        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;
        }