public void ProcessRequest(System.Web.HttpContext context)
        {
            var checker = new XamlBuildCheck() { Context = context };

            if (handler != null || checker.NeedsBuilding()) {
                if (handler == null) {
                    try {
            #if Silversite
                        var handlerInfo = Services.Lazy.Types.Info("XamlImageConverter.XamlImageHandler");
                        handlerInfo.Load();
                        handler = handlerInfo.New<IHttpHandler>();
            #else
                        var a = Assembly.LoadFrom(context.Server.MapPath("~/Bin/Lazy/XamlImageConverter.dll"));
                        var type = a.GetType("XamlImageConverter.XamlImageHandler");
                        handler = (System.Web.IHttpHandler)Activator.CreateInstance(type);
            #endif
                    } catch {
                        context.Response.StatusCode = 500;
                        context.ApplicationInstance.CompleteRequest();
                    }
                }
            #if Silversite
                context.Application.Lock();
                context.Application["XamlImageConverter.Configuration.UseService"] = Configuration.UseService;
                context.Application["XamlImageConverter.Configuration.Log"] = Configuration.Log;
                context.Application["XamlImageConverter.Configuration.Cache"] = Configuration.Cache;
                context.Application["XamlImageConverter.Configuration.SeparateDomain"] = Configuration.SeparateDomain;
                context.Application["XamlImageConverter.Configuration.GCLevel"] = Configuration.GCLevel;
                context.Application.UnLock();
            #endif
                handler.ProcessRequest(context);
            } else {
                var filename = context.Request.AppRelativeCurrentExecutionFilePath;
                var image = context.Request.QueryString["Image"] ?? context.Request.QueryString["File"] ?? context.Request.QueryString["Filename"];
                var ext = Path.GetExtension(filename).ToLower();
                if (ext == ".xaml" || ext == ".psd" || ext == ".svg" || ext == ".svgz") {
                    var exts = context.Request.QueryString.GetValues(null);
                    if (exts != null && exts.Length > 0) {
                        ext = exts[0];
                        image = image ?? filename + "." + ext;
                    }
                }
                var name = System.IO.Path.GetFileName(image);
                image = context.Server.MapPath(image);
                ext = System.IO.Path.GetExtension(image);
                if (!string.IsNullOrEmpty(ext)) ext = ext.Substring(1).ToLower();

                switch (ext) {
                    case "bmp": context.Response.ContentType = "image/bmp"; break;
                    case "png": context.Response.ContentType = "image/png"; break;
                    case "jpg":
                    case "jpeg":	context.Response.ContentType = "image/jpeg"; break;
                    case "tif":
                    case "tiff": context.Response.ContentType = "image/tiff"; break;
                    case "gif": context.Response.ContentType = "image/gif"; break;
                    case "wdp": context.Response.ContentType = "image/vnd.ms-photo"; break;
                    case "pdf":
                        context.Response.AppendHeader("content-disposition", "attachment; filename=" + name);
                        context.Response.ContentType = "application/pdf"; break;
                    case "xps":
                        context.Response.AppendHeader("content-disposition", "attachment; filename=" + name);
                        context.Response.ContentType = "application/vnd.ms-xpsdocument"; break;
                    case "eps":
                    case "ps":
                        context.Response.AppendHeader("content-disposition", "attachment; filename=" + name);
                        context.Response.ContentType = "application/postscript"; break;
                    case "psd":
                        context.Response.AppendHeader("content-disposition", "attachment; filename=" + name);
                        context.Response.ContentType = "image/photoshop"; break;
                    case "svg":
                    case "svgz": context.Response.ContentType = "image/svg+xml"; break;
                    case "xaml": context.Response.ContentType = "application/xaml+xml"; break;
                    default: break;
                }

                if (System.IO.File.Exists(image)) context.Response.WriteFile(image);
                else {
                    context.Response.StatusCode = 404;
                }
                context.ApplicationInstance.CompleteRequest();
            }
        }
 public Group(XamlBuildCheck fbc, string culture)
 {
     FBC = fbc;
     OldCulture = fbc.Culture;
     fbc.Culture = culture;
 }