Code minification result
Inheritance: MinificationResultBase
Ejemplo n.º 1
0
        private CodeMinificationResult InnerMinify(string content, bool isAngularBindingExpression)
        {
            if (string.IsNullOrWhiteSpace(content))
            {
                return(new CodeMinificationResult(string.Empty));
            }

            string newContent = string.Empty;
            var    errors     = new List <MinificationErrorInfo>();

            try
            {
                newContent = _originalJsMinifier.Minify(content, isAngularBindingExpression);
            }
            catch (JsMinificationException e)
            {
                errors.Add(new MinificationErrorInfo(e.Message));
            }

            var minificationResult = new CodeMinificationResult(newContent, errors);

            return(minificationResult);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Produces code minifiction of JS content by using C# port of
        /// Douglas Crockford's JSMin
        /// </summary>
        /// <param name="content">JS content</param>
        /// <param name="isInlineCode">Flag whether the content is inline code</param>
        /// <param name="encoding">Text encoding</param>
        /// <returns>Minification result</returns>
        public CodeMinificationResult Minify(string content, bool isInlineCode, Encoding encoding)
        {
            if (string.IsNullOrWhiteSpace(content))
            {
                return(new CodeMinificationResult(string.Empty));
            }

            string newContent = string.Empty;
            var    errors     = new List <MinificationErrorInfo>();

            try
            {
                newContent = _originalJsMinifier.Minify(content);
            }
            catch (JsMinificationException e)
            {
                errors.Add(new MinificationErrorInfo(e.Message));
            }

            var minificationResult = new CodeMinificationResult(newContent, errors);

            return(minificationResult);
        }
        /// <summary>
        /// Produces code minifiction of JS content by using C# port of
        /// Douglas Crockford's JSMin (version of May 22 2007)
        /// </summary>
        /// <param name="content">JS content</param>
        /// <param name="isInlineCode">Flag whether the content is inline code</param>
        /// <param name="encoding">Text encoding</param>
        /// <returns>Minification result</returns>
        public CodeMinificationResult Minify(string content, bool isInlineCode, Encoding encoding)
        {
            if (string.IsNullOrWhiteSpace(content))
            {
                return new CodeMinificationResult(string.Empty);
            }

            string newContent = string.Empty;
            var errors = new List<MinificationErrorInfo>();

            try
            {
                var jsMin = new JsMinifier();
                newContent = jsMin.Minify(content);
            }
            catch (JsMinificationException e)
            {
                errors.Add(new MinificationErrorInfo(e.Message));
            }

            var minificationResult = new CodeMinificationResult(newContent, errors);

            return minificationResult;
        }