Exemplo n.º 1
0
        public void ProcessRequest(HttpContext context)
        {
            String common  = context.Request.QueryString[CommonPackage];
            String package = context.Request.QueryString[SinglePackage];

            context.Response.ContentType = CssContentType;

            context.Response.Cache.VaryByHeaders["Accept-Encoding"] = true;
            context.Response.Cache.SetExpires(DateTime.Now.AddYears(1));
            //context.Response.Cache.SetCacheability(HttpCacheability.Public);

            if (!String.IsNullOrEmpty(common))
            {
                var ids     = common.Split('_').ToList();
                var idsLong = new List <long>();
                ids.ForEach(t => { long id; if (long.TryParse(t, out id))
                                   {
                                       idsLong.Add(id);
                                   }
                            });
                var plugins = ServiceLocator.Current.GetInstance <IPluginService>().FindPluginsByIds(idsLong);
                var file    = AssetsExtensions.CssPluginPackHelper(context, Application.Plugins.Where(t => plugins.Any(temp => temp.Identifier == t.Identifier)), common, null);
                if (!String.IsNullOrEmpty(file))
                {
                    context.Response.WriteFile(file);
                    return;
                }
            }
            if (!String.IsNullOrEmpty(package))
            {
                var file = AssetsHelper.BuildPluginCssPack(Application.Plugins.Where(t => t.Identifier == package).SingleOrDefault(), context.Request.PhysicalApplicationPath);
                if (!String.IsNullOrEmpty(file))
                {
                    context.Response.WriteFile(file);
                    return;
                }
            }
        }