Example #1
0
 public void RegisterBundle(NamedResource bundleResource, params string[] resolves)
 {
     foreach (var res in resolves)
     {
         BundleInverseIndex.Add(res, bundleResource);
     }
 }
Example #2
0
 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());
     }
 }
Example #3
0
        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
        }
Example #4
0
 public override IEnumerable <NamedResource> ProcessOne(NamedResource resource)
 => new[] { BundleInverseIndex[resource.Name] };
Example #5
0
 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));
Example #6
0
 public static void RenderResourceCached(this NamedResource resource, IHtmlWriter writer, IDotvvmRequestContext context)
 {
     writer.WriteUnencodedText(resource.GetRenderedTextCached(context));
 }
Example #7
0
 public abstract IEnumerable <NamedResource> ProcessOne(NamedResource resource);