예제 #1
0
        /// <summary>
        /// Include a stylesheet to fallback to when external CdnPath does not load.
        /// </summary>
        /// <param name="bundle"></param>
        /// <param name="fallback">Virtual path to fallback stylesheet</param>
        /// <param name="className">Stylesheet class name applied to test DOM element</param>
        /// <param name="ruleName">Rule name to test when the class is applied ie. width</param>
        /// <param name="ruleValue">Value to test when the class is applied ie. 1px</param>
        /// <returns></returns>
        public static StyleBundle IncludeFallback(this StyleBundle bundle, string fallback,
                                                  string className = null, string ruleName = null, string ruleValue = null)
        {
            if (String.IsNullOrEmpty(bundle.CdnPath))
            {
                throw new Exception("CdnPath must be provided when specifying a fallback");
            }

            if (VirtualPathUtility.IsAppRelative(bundle.CdnPath))
            {
                bundle.CdnFallbackExpress(fallback);
            }
            else if (new[] { className, ruleName, ruleValue }.Any(String.IsNullOrEmpty))
            {
                throw new Exception(
                          "IncludeFallback for cross-domain CdnPath must provide values for parameters [className, ruleName, ruleValue].");
            }
            else
            {
                bundle.CdnFallbackExpress(fallback, className, ruleName, ruleValue);
            }

            return(bundle);
        }