Example #1
0
        public static BlazorContext Create(IJSRuntime js, ILoggerFactory loggerFactory)
        {
            var ctx = new BlazorContext(null)
            {
                RootPath = Directory.GetCurrentDirectory(),
                EnableImplicitAutoload = true,
            };

            ctx.WorkingDirectory = ctx.RootPath;
            ctx.InitOutput(null);
            ctx.InitSuperglobals();
            ctx._js          = js;
            ctx._fileManager = new FileManager(ctx, loggerFactory);
            ctx._logger      = loggerFactory.CreateLogger <BlazorContext>();
            ctx.Output       = BlazorWriter.CreateConsole();

            ctx.CallJsVoid("window.php.init", ctx._objRef);

            //
            ctx.AutoloadFiles();

            //
            return(ctx);
        }
Example #2
0
 /// <summary>
 /// Sets the context to redirect the script output into the console.
 /// </summary>
 public void StopRender()
 {
     Output.Flush();
     Output.Dispose();
     Output = BlazorWriter.CreateConsole();
 }
Example #3
0
 /// <summary>
 /// Sets the context to redirect the script output into the builder.
 /// </summary>
 public void StartRender(Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder builder)
 {
     Output = BlazorWriter.CreateTree(builder);
 }
Example #4
0
 protected BlazorContext(IServiceProvider services) : base(services)
 {
     Output  = BlazorWriter.CreateConsole();
     _objRef = DotNetObjectReference.Create <BlazorContext>(this);
 }