コード例 #1
0
 public FileManager(BlazorContext ctx, ILoggerFactory factory)
 {
     _ctx        = ctx;
     _fetched    = new List <FormFile>();
     _downloaded = new Dictionary <int, string>();
     _logger     = factory.CreateLogger <FileManager>();
 }
コード例 #2
0
        /// <summary>
        /// Evaluates the script with given Blazor context and render tree builder.
        /// </summary>
        public static PhpValue Evaluate(this Context.ScriptInfo script, BlazorContext ctx, Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder builder)
        {
            ctx.StartRender(builder);
            var result = script.Evaluate(ctx, ctx.Globals, null);

            ctx.StopRender();

            return(result);
        }
コード例 #3
0
        Task IComponent.SetParametersAsync(ParameterView parameters)
        {
            parameters.SetParameterProperties(this);

            Log.SetParameters(_logger, _firstRendering, Type, ContextLifetime);

            if (_firstRendering)
            {
                _firstRendering = false;
                _ctx            = BlazorContext.Create(this);
                Refresh();
            }

            return(Task.CompletedTask);
        }
コード例 #4
0
        private void OnLocationChanged(object sender, LocationChangedEventArgs args)
        {
            Log.Navigation(_logger, args.Location, _disposed);

            if (_disposed)
            {
                return;
            }

            if (ContextLifetime == SessionLifetime.OnNavigationChanged)
            {
                _ctx?.Dispose();
                _ctx = BlazorContext.Create(this);
            }

            Refresh();
        }
コード例 #5
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);
        }