-
Notifications
You must be signed in to change notification settings - Fork 0
/
NetzlibModule.cs
42 lines (34 loc) · 952 Bytes
/
NetzlibModule.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
using System;
using System.Web;
using System.Web.UI;
using netzlib.Javascript;
namespace netzlib
{
public class NetzlibModule : IHttpModule
{
internal static readonly string RESOURCE_REPOSITORY = typeof(IResourceRepository).FullName;
static readonly IResourceRepository resources = new ResourceRepository();
public void Init(HttpApplication context)
{
context.Application[RESOURCE_REPOSITORY] = resources;
context.PostMapRequestHandler += OnPostMapRequestHandler;
}
static void OnPostMapRequestHandler(object sender, EventArgs e)
{
var ctx = HttpContext.Current;
if(ctx != null && ctx.CurrentHandler is Page)
{
var tagFilter = new TagFilter();
ctx.Response.Filter = tagFilter;
if (Javascript.Settings.Default.Enabled)
{
var jsCombinator = new JavascriptCombiner(ctx.Request.Url, resources);
tagFilter.Filter += jsCombinator.Filter;
}
}
}
public void Dispose()
{
}
}
}