public void RegisterBundle(NamedResource bundleResource, params string[] resolves) { foreach (var res in resolves) { BundleInverseIndex.Add(res, bundleResource); } }
private static string RenderToString(NamedResource resource, IDotvvmRequestContext context) { using (var text = new StringWriter()) { resource.Resource.Render(new HtmlWriter(text, context), context, resource.Name); return(text.ToString()); } }
static void WriteResourceInfo(NamedResource resource, IHtmlWriter writer, bool preload) { var comment = $"Resource {resource.Name} of type {resource.Resource.GetType().Name}."; if (resource.Resource is ILinkResource linkResource) { comment += $" Pointing to {string.Join(", ", linkResource.GetLocations().Select(l => l.GetType().Name))}."; } if (preload) { comment = "[preload link] " + comment; } writer.WriteUnencodedText("\n <!-- "); writer.WriteText(comment); writer.WriteUnencodedText(" -->\n "); // ^~~~ most likely this info will be written directly in the <body> or <head>, so it should be indented by one level. // we don't have any better way to know how we should indent }
public override IEnumerable <NamedResource> ProcessOne(NamedResource resource) => new[] { BundleInverseIndex[resource.Name] };
public static string GetRenderedTextCached(this NamedResource resource, IDotvvmRequestContext context) => // don't use cache when debug, so the resource can be refreshed when file is changed context.Configuration.Debug ? RenderToString(resource, context) : renderedCache.GetValue(resource.Resource, _ => RenderToString(resource, context));
public static void RenderResourceCached(this NamedResource resource, IHtmlWriter writer, IDotvvmRequestContext context) { writer.WriteUnencodedText(resource.GetRenderedTextCached(context)); }
public abstract IEnumerable <NamedResource> ProcessOne(NamedResource resource);