/// <summary> /// Constructs instance of markup minification result /// </summary> /// <param name="minifiedContent">Minified content</param> /// <param name="errors">List of the errors</param> /// <param name="warnings">List of the warnings</param> /// <param name="statistics">Minification statistics</param> public MarkupMinificationResult(string minifiedContent, IList <MinificationErrorInfo> errors, IList <MinificationErrorInfo> warnings, MinificationStatistics statistics) : base(minifiedContent, errors, warnings) { Statistics = statistics; }
/// <summary> /// Minify XML content /// </summary> /// <param name="content">XML content</param> /// <param name="fileContext">File context</param> /// <param name="encoding">Text encoding</param> /// <param name="generateStatistics">Flag for whether to allow generate minification statistics</param> /// <returns>Minification result</returns> public MarkupMinificationResult Minify(string content, string fileContext, Encoding encoding, bool generateStatistics) { MinificationStatistics statistics = null; string minifiedContent = string.Empty; var errors = new List <MinificationErrorInfo>(); lock (_minificationSynchronizer) { try { if (generateStatistics) { statistics = new MinificationStatistics(encoding); statistics.Init(content); } _result = new StringBuilder(content.Length); _buffer = new List <string>(); _errors = new List <MinificationErrorInfo>(); _currentNodeType = XmlNodeType.Unknown; _currentText = string.Empty; _xmlParser.Parse(content); FlushBuffer(); if (_errors.Count == 0) { minifiedContent = _result.ToString(); if (generateStatistics) { statistics.End(minifiedContent); } } } catch (XmlParsingException e) { WriteError(ErrorCategoryCode.XmlParsingError, e.Message, fileContext, e.LineNumber, e.ColumnNumber, e.SourceFragment); } finally { _result.Clear(); _buffer.Clear(); } if (_errors.Count == 0) { _logger.Info(ErrorCategoryCode.XmlMinificationSuccess, string.Format(Strings.SuccesMessage_MarkupMinificationComplete, "XML"), fileContext, statistics); } errors.AddRange(_errors); _errors.Clear(); } return(new MarkupMinificationResult(minifiedContent, errors, statistics)); }
/// <summary> /// Constructs instance of markup minification result /// </summary> /// <param name="minifiedContent">Minified content</param> /// <param name="errors">List of the errors</param> /// <param name="statistics">Minification statistics</param> public MarkupMinificationResult(string minifiedContent, IList <MinificationErrorInfo> errors, MinificationStatistics statistics) : this(minifiedContent, errors, new List <MinificationErrorInfo>(), statistics) { }