protected override void BuildRenderTree(RenderTreeBuilder builder)
        {
            //This component must be rendered once!
            //Even if the javascript script is not re-renderer if the component is called twice, it should be already available in the DOM
            if (_isInitialized)
            {
                return;
            }

            builder.OpenElement(0, "script");
            builder.AddAttribute(1, "type", "text/javascript");
            builder.AddMarkupContent(1,
                                     ContextBridgeHelper.GetBlazorXamarinJavascript()
                                     + ContextBridgeHelper.GetContextBridgeJavascript().Replace("%_contextBridgeURI%", BlazorMobileService.GetContextBridgeURI()));
            builder.CloseElement();

            _isInitialized = true;
        }
        protected override void BuildRenderTree(RenderTreeBuilder builder)
        {
            //This component must be rendered once!
            //If the component is disposed and then re-rendered, then something is wrong with the current project configuration
            if (_isInitialized)
            {
                return;
            }

            builder.OpenElement(0, "script");
            builder.AddAttribute(1, "type", "text/javascript");
            builder.AddContent(1,
                               ContextBridgeHelper.GetBlazorXamarinJavascript()
                               + ContextBridgeHelper.GetContextBridgeJavascript().Replace("%_contextBridgeURI%", BlazorMobileService.GetContextBridgeURI()));
            builder.CloseElement();

            _isInitialized = true;
        }
        protected override void BuildRenderTree(RenderTreeBuilder builder)
        {
            //This component must be rendered once!
            //If the component is disposed and then re-rendered, then something is wrong with the current project configuration
            if (_isInitialized)
            {
                return;
            }

            if (ContextHelper.IsBlazorMobile())
            {
                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%", BlazorMobileService.GetContextBridgeURI()));
                builder.CloseElement();
            }
            else if (ContextHelper.IsElectronNET())
            {
                //Add electronNET helpers
                builder.OpenElement(0, "script");
                builder.AddContent(1, ContextBridgeHelper.GetElectronNETJavascript());
                builder.CloseElement();
            }

            _isInitialized = true;
        }
示例#4
0
 private async Task SetRemoteDebugEndpoint()
 {
     string uri = BlazorMobileService.GetContextBridgeURI();
     await Runtime.InvokeVoidAsync("BlazorXamarin.SetDebugRemoteEndpoint", uri);
 }