Example #1
0
        /// <summary>
        /// Creates a instance of CSS minifier based on the settings
        /// that specified in configuration files (App.config or Web.config)
        /// </summary>
        /// <param name="name">CSS minifier name</param>
        /// <param name="loadSettingsFromConfigurationFile">Flag for whether to allow
        /// loading minifier settings from configuration file</param>
        /// <returns>CSS minifier</returns>
        public ICssMinifier CreateCssMinifierInstance(string name,
                                                      bool loadSettingsFromConfigurationFile = true)
        {
            ICssMinifier cssMinifier;
            Dictionary <string, CodeMinifierInfo> cssMinifierRegistry = GetCssMinifierRegistry();

            if (cssMinifierRegistry.ContainsKey(name))
            {
                CodeMinifierInfo cssMinifierInfo = cssMinifierRegistry[name];

                cssMinifier = Utils.CreateInstanceByFullTypeName <ICssMinifier>(cssMinifierInfo.Type);
                if (loadSettingsFromConfigurationFile)
                {
                    cssMinifier.LoadSettingsFromConfigurationFile();
                }
            }
            else
            {
                throw new CodeMinifierNotFoundException(
                          string.Format(Strings.Configuration_CodeMinifierNotRegistered, "CSS", name));
            }

            return(cssMinifier);
        }
Example #2
0
        /// <summary>
        /// Creates a instance of JS minifier based on the settings
        /// that specified in configuration files (App.config or Web.config)
        /// </summary>
        /// <param name="name">JS minifier name</param>
        /// <param name="loadSettingsFromConfigurationFile">Flag for whether to allow
        /// loading minifier settings from configuration file</param>
        /// <returns>JS minifier</returns>
        public IJsMinifier CreateJsMinifierInstance(string name,
                                                    bool loadSettingsFromConfigurationFile = true)
        {
            IJsMinifier jsMinifier;
            Dictionary <string, CodeMinifierInfo> jsMinifierRegisty = GetJsMinifierRegistry();

            if (jsMinifierRegisty.ContainsKey(name))
            {
                CodeMinifierInfo jsMinifierInfo = jsMinifierRegisty[name];

                jsMinifier = Utils.CreateInstanceByFullTypeName <IJsMinifier>(jsMinifierInfo.Type);
                if (loadSettingsFromConfigurationFile)
                {
                    jsMinifier.LoadSettingsFromConfigurationFile();
                }
            }
            else
            {
                throw new CodeMinifierNotFoundException(
                          string.Format(Strings.Configuration_CodeMinifierNotRegistered, "JS", name));
            }

            return(jsMinifier);
        }