예제 #1
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
        {
            app.UseResponseCompression();

            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
                app.UseBlazorDebugging();
            }
            else
            {
                app.UseExceptionHandler("/Home/Error");
            }

            app.UseClientSideBlazorFiles <InteropBlazorApp.Startup>();

            app.UseRouting();

            app.UseEndpoints(endpoints =>
            {
                var componentBuilder = endpoints.MapBlazorHub <MobileApp>("app");
                endpoints.MapDefaultControllerRoute();
                endpoints.MapFallbackToClientSideBlazor <InteropBlazorApp.Startup>("index.html");

                BlazorService.EnableClientToDeviceRemoteDebugging("127.0.0.1", 8888);
                BlazorService.Init(componentBuilder, (bool success) =>
                {
                    Console.WriteLine($"Initialization success: {success}");
                    Console.WriteLine("Device is: " + Device.RuntimePlatform);
                });
            });
        }
예제 #2
0
        public void Configure(IComponentsApplicationBuilder app)
        {
            #region DEBUG

            //Only if you want to test WebAssembly with remote debugging from a dev machine
            BlazorService.EnableClientToDeviceRemoteDebugging("192.168.1.118", 8888);

            #endregion

            BlazorService.Init(app, (bool success) =>
            {
                Console.WriteLine($"Initialization success: {success}");
                Console.WriteLine("Device is: " + Device.RuntimePlatform);
            });

            app.AddComponent <MobileApp>("app");
        }
예제 #3
0
        protected override void BuildRenderTree(RenderTreeBuilder builder)
        {
            //This component must be rendered once!
            if (_isInitialized)
            {
                return;
            }

            builder.OpenElement(0, "script");
            builder.AddContent(1, @"
    window.BlazorXamarinRuntimeCheck = function () {
        if (window.contextBridge == null || window.contextBridge == undefined)
        {
            return false;
        }
    
        return true;
    };
");
            builder.CloseElement();

            //Add server side remote to client remote debugging
            builder.OpenElement(0, "script");
            builder.AddContent(1, ContextBridgeHelper.GetInjectableJavascript(false).Replace("%_contextBridgeURI%", BlazorService.GetContextBridgeURI()));
            builder.CloseElement();

            _isInitialized = true;
        }