Пример #1
0
        protected override (CircuitHost, bool) ConnectCore(CircuitId circuitId, IClientProxy clientProxy, string connectionId)
        {
            if (BeforeConnect != null)
            {
                Assert.True(BeforeConnect?.Wait(TimeSpan.FromSeconds(10)), "BeforeConnect failed to be set");
            }

            return(base.ConnectCore(circuitId, clientProxy, connectionId));
        }
Пример #2
0
            public static void CreatedCircuit(ILogger logger, CircuitId circuitId, string circuitSecret, string connectionId)
            {
                // Redact the secret unless tracing is on.
                if (!logger.IsEnabled(LogLevel.Trace))
                {
                    circuitSecret = "(redacted)";
                }

                _createdCircuit(logger, circuitId, circuitSecret, connectionId, null);
            }
Пример #3
0
    public CircuitHost(
        CircuitId circuitId,
        AsyncServiceScope scope,
        CircuitOptions options,
        CircuitClientProxy client,
        RemoteRenderer renderer,
        IReadOnlyList <ComponentDescriptor> descriptors,
        RemoteJSRuntime jsRuntime,
        RemoteNavigationManager navigationManager,
        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));
        _navigationManager = navigationManager ?? throw new ArgumentNullException(nameof(navigationManager));
        _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;

        _navigationManager.UnhandledException += ReportAndInvoke_UnhandledException;
    }
Пример #4
0
    public bool TryParseCircuitId(string?text, out CircuitId circuitId)
    {
        if (text is null)
        {
            circuitId = default;
            return(false);
        }

        try
        {
            var protectedBytes   = Base64UrlTextEncoder.Decode(text);
            var unprotectedBytes = _protector.Unprotect(protectedBytes);

            if (unprotectedBytes.Length != SecretLength)
            {
                // Wrong length
                circuitId = default;
                return(false);
            }

            var id = new byte[IdLength];
            Array.Copy(
                sourceArray: unprotectedBytes,
                sourceIndex: SecretLength - IdLength,
                destinationArray: id,
                destinationIndex: 0,
                length: IdLength);

            circuitId = new CircuitId(text, Base64UrlTextEncoder.Encode(id));
            return(true);
        }
        catch (Exception)
        {
            // The payload format is not correct (either not base64urlencoded or not data protected)
            circuitId = default;
            return(false);
        }
    }
Пример #5
0
 public static void CircuitAlreadyInitialized(ILogger logger, CircuitId circuitId) => _circuitAlreadyInitialized(logger, circuitId, null);
Пример #6
0
 private TestCircuitHost(CircuitId circuitId, AsyncServiceScope scope, CircuitOptions options, CircuitClientProxy client, RemoteRenderer renderer, IReadOnlyList <ComponentDescriptor> descriptors, RemoteJSRuntime jsRuntime, RemoteNavigationManager navigationManager, CircuitHandler[] circuitHandlers, ILogger logger)
     : base(circuitId, scope, options, client, renderer, descriptors, jsRuntime, navigationManager, circuitHandlers, logger)
 {
 }
Пример #7
0
 private static partial void CreatedCircuitCore(ILogger logger, CircuitId circuitId, string circuitIdSecret, string connectionId);
Пример #8
0
 public static partial void CircuitAlreadyInitialized(ILogger logger, CircuitId circuitId);