/// <summary>
        /// Creates an instance of <see cref="WebAssemblyHostBuilder"/> with the minimal configuration.
        /// </summary>
        internal WebAssemblyHostBuilder(IJSUnmarshalledRuntime jsRuntime)
        {
            // Private right now because we don't have much reason to expose it. This can be exposed
            // in the future if we want to give people a choice between CreateDefault and something
            // less opinionated.
            Configuration  = new WebAssemblyHostConfiguration();
            RootComponents = new RootComponentMappingCollection();
            Services       = new ServiceCollection();
            Logging        = new LoggingBuilder(Services);

            // Retrieve required attributes from JSRuntimeInvoker
            InitializeNavigationManager(jsRuntime);
            InitializeRegisteredRootComponents(jsRuntime);
            InitializePersistedState(jsRuntime);
            InitializeDefaultServices();

            var hostEnvironment = InitializeEnvironment(jsRuntime);

            HostEnvironment = hostEnvironment;

            _createServiceProvider = () =>
            {
                return(Services.BuildServiceProvider(validateScopes: WebAssemblyHostEnvironmentExtensions.IsDevelopment(hostEnvironment)));
            };
        }
示例#2
0
        internal WebAssemblyHost(
            WebAssemblyHostBuilder builder,
            IServiceProvider services,
            AsyncServiceScope scope,
            string?persistedState)
        {
            // To ensure JS-invoked methods don't get linked out, have a reference to their enclosing types
            GC.KeepAlive(typeof(JSInteropMethods));

            _services       = services;
            _scope          = scope;
            _configuration  = builder.Configuration;
            _rootComponents = builder.RootComponents;
            _persistedState = persistedState;
        }
示例#3
0
        internal WebAssemblyHost(
            IServiceProvider services,
            IServiceScope scope,
            IConfiguration configuration,
            RootComponentMappingCollection rootComponents,
            string?persistedState)
        {
            // To ensure JS-invoked methods don't get linked out, have a reference to their enclosing types
            GC.KeepAlive(typeof(JSInteropMethods));

            _services       = services;
            _scope          = scope;
            _configuration  = configuration;
            _rootComponents = rootComponents;
            _persistedState = persistedState;
        }