/// <summary> /// Constructs a instance of Sergey Kryzhanovsky's CSS minifier /// </summary> /// <param name="createJsEngineInstance">Delegate that creates an instance of JS engine</param> /// <param name="cssoConfig">Configuration settings of Sergey Kryzhanovsky's Minifier</param> public KryzhanovskyCssMinifier(Func <IJsEngine> createJsEngineInstance, CssoSettings cssoConfig) { CssMinifierSettings cssMinifierConfig = cssoConfig.CssMinifier; DisableRestructuring = cssMinifierConfig.DisableRestructuring; ForceMediaMerge = cssMinifierConfig.ForceMediaMerge; Comments = cssMinifierConfig.Comments; if (createJsEngineInstance == null) { string jsEngineName = cssoConfig.JsEngine.Name; if (string.IsNullOrWhiteSpace(jsEngineName)) { throw new ConfigurationErrorsException( string.Format(CoreStrings.Configuration_JsEngineNotSpecified, "csso", @" * JavaScriptEngineSwitcher.Msie (only in the Chakra JsRT modes) * JavaScriptEngineSwitcher.V8 * JavaScriptEngineSwitcher.ChakraCore", "MsieJsEngine") ); } createJsEngineInstance = () => JsEngineSwitcher.Instance.CreateEngine(jsEngineName); } _createJsEngineInstance = createJsEngineInstance; }
/// <summary> /// Constructs a instance of Sergey Kryzhanovsky's CSS-minifier /// </summary> /// <param name="createJsEngineInstance">Delegate that creates an instance of JavaScript engine</param> /// <param name="cssoConfig">Configuration settings of Sergey Kryzhanovsky's Minifier</param> public KryzhanovskyCssMinifier(Func<IJsEngine> createJsEngineInstance, CssoSettings cssoConfig) { DisableRestructuring = cssoConfig.CssMinifier.DisableRestructuring; if (createJsEngineInstance == null) { string jsEngineName = cssoConfig.JsEngine.Name; if (string.IsNullOrWhiteSpace(jsEngineName)) { throw new ConfigurationErrorsException( string.Format(CoreStrings.Configuration_JsEngineNotSpecified, "csso", @" * JavaScriptEngineSwitcher.Msie * JavaScriptEngineSwitcher.V8", "MsieJsEngine") ); } createJsEngineInstance = (() => JsEngineSwitcher.Current.CreateJsEngineInstance(jsEngineName)); } _createJsEngineInstance = createJsEngineInstance; }