Ejemplo n.º 1
0
        /// <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)));
            };
        }
Ejemplo n.º 2
0
        public void Builder_InDevelopment_SetsHostEnvironmentProperty()
        {
            // Arrange
            var builder = new WebAssemblyHostBuilder(new TestJSUnmarshalledRuntime(environment: "Development"));

            // Assert
            Assert.NotNull(builder.HostEnvironment);
            Assert.True(WebAssemblyHostEnvironmentExtensions.IsDevelopment(builder.HostEnvironment));
        }