private void RenderAssets(IControlOutputContext context, RendererTagAttributes attributes) { var assetPaths = this.ResolveAssetPaths(context); var currentHttpContext = context.GetHttpContext(); var optimizationScope = currentHttpContext.RequestServices.GetRequiredService <IOptimizationScope>(); var optimizationContext = optimizationScope.AddOrGetContext(this.OptimizationContextName); foreach (var assetPath in assetPaths) { optimizationContext.AddAsset(assetPath); } }
protected override async Task ProcessAsync(IControlOutputContext context) { if (string.IsNullOrWhiteSpace(this.Name)) { this.Name = Options.DefaultName; } RendererTagAttributes rendererAttributes = new RendererTagAttributes( this.TagHelperContext.AllAttributes.Where(attr => 0 != string.Compare(attr.Name, nameof(this.Name), StringComparison.OrdinalIgnoreCase)) ); var controlRenderer = this.RendererFactory.GetRenderer(this.Name); await controlRenderer.RenderAsync(context, rendererAttributes); }
public virtual void Render(IControlOutputContext context, RendererTagAttributes attributes) { this.RendererControl = context.Control as RendererTagHelper; if (null == context.Parent) { if (1 != context.Children.Count) { throw new Exception(); } context.Output.TagName = string.Empty; this.RenderRootControl(context.Children[0]); context.Children[0].Output.Content.MoveTo(context.Output.Content); this.RenderAssets(context, attributes); } }
public virtual async Task RenderAsync(IControlOutputContext context, RendererTagAttributes attributes) { this.RendererControl = context.Control as RendererTagHelper; if (null == context.Parent) { if (1 != context.Children.Count) { throw new Exception(); } context.Output.TagName = string.Empty; this.RenderRootControl((TControl)context.Children[0].Control, context.Children[0]); context.Children[0].Output.PreContent.MoveTo(context.Output.PreContent); context.Children[0].Output.Content.MoveTo(context.Output.Content); context.Children[0].Output.PostContent.MoveTo(context.Output.PostContent); await this.RenderAssetsAsync(context); } }
public virtual void Render(IControlOutputContext context, RendererTagAttributes attributes) { Task renderTask = this.RenderAsync(context, attributes); renderTask.GetAwaiter().GetResult(); }
protected virtual async Task RenderAssetAsync(IOptimizationResultTagBuilder optimizationResultTagBuilder, RendererTagAttributes attributes, Asset asset, string extension, IHtmlContentBuilder htmlContentBuilder) { TagBuilderOptions options = new TagBuilderOptions(extension, OptimizationTagOutput.Tag); await optimizationResultTagBuilder.PopulateHtmlTagAsync(options, attributes, asset, htmlContentBuilder); }
public virtual async Task RenderAsync(IControlOutputContext context, RendererTagAttributes attributes) { await Task.CompletedTask; this.Render(context, attributes); }
public void Render(IControlOutputContext context, RendererTagAttributes attributes) { context.Output.SuppressOutput(); }
public Task RenderAsync(IControlOutputContext context, RendererTagAttributes attributes) { this.Render(context, attributes); return(Task.CompletedTask); }