Example #1
0
        /// <summary>
        /// Generates HTML markup for including css-files specified in assets config (<see cref="AssetPackagesConfigPath"/>).
        /// </summary>
        /// <param name="context">Current http context.</param>
        /// <param name="packageName">Name of the package specified in assets config.</param>
        /// <param name="htmlAttributes">The HTML attributes.</param>
        /// <returns>HTML markup for including css-file specified in assets config.</returns>
        private static String CssPackHelper(HttpContextBase context, String packageName, RouteValueDictionary htmlAttributes)
        {
            var builder     = new StringBuilder();
            var environment = GetEnvironment();
            var configPath  = context.Server.MapPath(AssetPackagesConfigPath);

            if (Environment.Development.Equals(environment))
            {
                foreach (var file in AssetsHelper.GetCssPackFiles(environment, packageName, configPath))
                {
                    builder.Append(CssHelper(context, file, htmlAttributes));
                }
            }
            else
            {
                var cssServerPath   = context.Server.MapPath(CssPath);
                var packageFileName = AssetsHelper.BuildCssPack(environment, packageName, cssServerPath, configPath);
                builder.Append(CssHelper(context, VirtualPathUtility.Combine(CssPath, packageFileName), htmlAttributes));
            }
            return(builder.ToString());
        }