2 // System.Web.Handlers.AssemblyResourceLoader
5 // Ben Maurer (bmaurer@users.sourceforge.net)
12 using System.Reflection;
15 namespace System.Web.Handlers {
16 [MonoTODO ("Should we cache stuff?")]
20 internal // since this is in the .config file, we need to support it, since we dont have versoned support.
22 class AssemblyResourceLoader : IHttpHandler {
24 internal static string GetResourceUrl (Type type, string resourceName)
26 return "WebResource.axd?assembly="
27 + HttpUtility.UrlEncode (type.Assembly.GetName ().FullName)
29 + HttpUtility.UrlEncode (resourceName);
33 [MonoTODO ("Substitution not implemented")]
34 void System.Web.IHttpHandler.ProcessRequest (HttpContext context)
37 string resourceName = context.Request.QueryString ["resource"];
38 Assembly assembly = Assembly.Load (context.Request.QueryString ["assembly"]);
41 foreach (WebResourceAttribute wra in assembly.GetCustomAttributes (typeof (WebResourceAttribute), false)) {
42 if (wra.WebResource == resourceName) {
43 context.Response.ContentType = wra.ContentType;
45 if (wra.PerformSubstitution)
46 throw new NotImplementedException ("Substitution not implemented");
55 Stream s = assembly.GetManifestResourceStream (resourceName);
57 byte [] buf = new byte [1024];
58 Stream output = context.Response.OutputStream;
61 c = s.Read (buf, 0, 1024);
62 output.Write (buf, 0, c);
67 bool System.Web.IHttpHandler.IsReusable { get { return true; } }