コード例 #1
0
ファイル: iam.ui.aspx.cs プロジェクト: radtek/safeid
        protected void Page_Load(object sender, EventArgs e)
        {
            Page.Response.ContentType     = "text/css; charset=UTF-8";
            Page.Response.ContentEncoding = Encoding.UTF8;

            String text = "";

            if (String.IsNullOrWhiteSpace((String)Session["cssui"]))
            {
                String basePath = Path.Combine(Server.MapPath("~"), "css");

                List <FileInfo> files = new List <FileInfo>();
                files.Add(new FileInfo(Path.Combine(basePath, "iam.ui.fonts.css")));
                files.Add(new FileInfo(Path.Combine(basePath, "iam.ui.css")));
                files.Add(new FileInfo(Path.Combine(basePath, "jquery-ui-1.10.4.autocomplete.css")));
                files.Add(new FileInfo(Path.Combine(basePath, "iam.ui.login.css")));
                files.Add(new FileInfo(Path.Combine(basePath, "iam.ui.admin.css")));

                StringBuilder tmpText = new StringBuilder();
                tmpText.AppendLine("/*! SafeId v1.0.0 | (c) 2013 SafeTrend.com.br.");
                tmpText.AppendLine("//@ SafeID UI Style");
                tmpText.AppendLine("//@ Generated: " + DateTime.Now.ToString("yyyy-MM:dd HH:mm:ss"));
                tmpText.AppendLine("*/");
                tmpText.AppendLine("");

                foreach (FileInfo f in files)
                {
                    try
                    {
                        if (File.Exists(f.FullName))
                        {
                            using (TextReader tr = File.OpenText(f.FullName))
                                tmpText.Append(Minify.minifyCss(tr.ReadToEnd()));
                        }
                        else
                        {
#if DEBUG
                            tmpText.AppendLine("/*File not found " + f.Name + "*/");
#endif
                        }
                    }
                    catch { }
                }

                text = tmpText.ToString();
#if !DEBUG
                Session["cssui"] = text;
#endif
            }
            else
            {
                text = (String)Session["cssui"];
            }

            Byte[] bRet = Encoding.UTF8.GetBytes(text);
            Page.Response.Status     = "200 OK";
            Page.Response.StatusCode = 200;
            Page.Response.OutputStream.Write(bRet, 0, bRet.Length);
            Page.Response.OutputStream.Flush();
        }
コード例 #2
0
        private Config Clone()
        {
            var clone = (Config)MemberwiseClone();

            clone.Minify  = Minify.AsEnumerable().ToDictionary(kvp => kvp.Key, kvp => kvp.Value);
            clone.Options = Options.AsEnumerable().ToDictionary(kvp => kvp.Key, kvp => kvp.Value);
            return(clone);
        }
コード例 #3
0
 public static FilesTransformer Minify(this FilesTransformer options, Minify minify, Run behavior = Run.OnlyInDebug) => options.Clone(with: o => {
     if (minify.HasFlag(Html.Minify.JavaScript))
     {
         o.GetExt("js")?.FilesTransformers.Add(new MinifyBlock(Minifiers.JavaScript, behavior));
     }
     if (minify.HasFlag(Html.Minify.Css))
     {
         o.GetExt("css")?.FilesTransformers.Add(new MinifyBlock(Minifiers.Css, behavior));
     }
     if (minify.HasFlag(Html.Minify.HtmlAdvanced))
     {
         o.GetExt("html")?.FilesTransformers.Add(new MinifyBlock(Minifiers.HtmlAdvanced, behavior));
     }
     if (minify.HasFlag(Html.Minify.Html))
     {
         o.GetExt("html")?.FilesTransformers.Add(new MinifyBlock(Minifiers.Html, behavior));
     }
 });