/// <summary>
        /// Constructs a instance of XML minification manager
        /// </summary>
        /// <param name="settings">XML minification settings</param>
        /// <param name="logger">Logger</param>
        public XmlMinificationManager(XmlMinificationSettings settings, ILogger logger)
        {
            MinificationSettings = settings;
            SupportedMediaTypes = new HashSet<string>(MediaTypeGroupConstants.Xml);
            IncludedPages = new List<IUrlMatcher>();
            ExcludedPages = new List<IUrlMatcher>();

            Logger = logger;
        }
示例#2
0
        /// <summary>
        /// Creates a instance of XML minifier based on the settings
        /// that specified in configuration files (App.config or Web.config)
        /// </summary>
        /// <param name="settings">XML minification settings</param>
        /// <param name="logger">logger</param>
        /// <returns>XML minifier</returns>
        public XmlMinifier CreateXmlMinifierInstance(XmlMinificationSettings settings = null, ILogger logger = null)
        {
            XmlMinificationSettings innerSettings = settings ?? GetXmlMinificationSettings();
            ILogger innerLogger = logger ?? _wmmContext.GetDefaultLoggerInstance();

            var xmlMinifier = new XmlMinifier(innerSettings, innerLogger);

            return(xmlMinifier);
        }
示例#3
0
        /// <summary>
        /// Gets a XML minification settings based on data from
        /// configuration files (App.config or Web.config)
        /// </summary>
        /// <returns>XML minification settings</returns>
        public XmlMinificationSettings GetXmlMinificationSettings()
        {
            XmlMinificationConfiguration xmlConfig = _wmmContext.GetCoreConfiguration().Xml;
            var xmlSettings = new XmlMinificationSettings
            {
                MinifyWhitespace           = xmlConfig.MinifyWhitespace,
                RemoveXmlComments          = xmlConfig.RemoveXmlComments,
                RenderEmptyTagsWithSpace   = xmlConfig.RenderEmptyTagsWithSpace,
                CollapseTagsWithoutContent = xmlConfig.CollapseTagsWithoutContent
            };

            return(xmlSettings);
        }
示例#4
0
 /// <summary>
 /// Constructs instance of XML minifier
 /// </summary>
 /// <param name="settings">XML minification settings</param>
 /// <param name="logger">Logger</param>
 public XmlMinifier(XmlMinificationSettings settings = null, ILogger logger = null)
 {
     _settings  = settings ?? new XmlMinificationSettings();
     _logger    = logger ?? new NullLogger();
     _xmlParser = new XmlParser(new XmlParsingHandlers
     {
         XmlDeclaration        = XmlDeclarationHandler,
         ProcessingInstruction = ProcessingInstructionHandler,
         Doctype      = DoctypeDelegateHandler,
         Comment      = CommentHandler,
         CdataSection = CdataSectionHandler,
         StartTag     = StartTagHandler,
         EndTag       = EndTagHandler,
         EmptyTag     = EmptyTagHandler,
         Text         = TextHandler
     });
 }
示例#5
0
        /// <summary>
        /// Constructs instance of XML minifier
        /// </summary>
        /// <param name="settings">XML minification settings</param>
        /// <param name="logger">Logger</param>
        public XmlMinifier(XmlMinificationSettings settings = null, ILogger logger = null)
        {
            _settings  = settings ?? new XmlMinificationSettings();
            _logger    = logger ?? new NullLogger();
            _xmlParser = new XmlParser(new XmlParsingHandlers
            {
                XmlDeclaration        = XmlDeclarationHandler,
                ProcessingInstruction = ProcessingInstructionHandler,
                Doctype      = DoctypeDelegateHandler,
                Comment      = CommentHandler,
                CdataSection = CdataSectionHandler,
                StartTag     = StartTagHandler,
                EndTag       = EndTagHandler,
                EmptyTag     = EmptyTagHandler,
                Text         = TextHandler
            });

            _buffer          = new List <string>();
            _errors          = new List <MinificationErrorInfo>();
            _currentNodeType = XmlNodeType.Unknown;
            _currentText     = string.Empty;
        }
示例#6
0
 /// <summary>
 /// Constructs instance of XML minifier
 /// </summary>
 /// <param name="settings">XML minification settings</param>
 /// <param name="logger">Logger</param>
 public XmlMinifier(XmlMinificationSettings settings = null, ILogger logger = null)
 {
     _settings = settings ?? new XmlMinificationSettings();
     _logger = logger ?? new NullLogger();
     _xmlParser = new XmlParser(new XmlParsingHandlers
     {
         XmlDeclaration = XmlDeclarationHandler,
         ProcessingInstruction = ProcessingInstructionHandler,
         Doctype = DoctypeDelegateHandler,
         Comment = CommentHandler,
         CdataSection = CdataSectionHandler,
         StartTag = StartTagHandler,
         EndTag = EndTagHandler,
         EmptyTag = EmptyTagHandler,
         Text = TextHandler
     });
 }
示例#7
0
文件: MinifyXml.cs 项目: ibebbs/Wyam
 /// <summary>
 /// Minifies the XML content.
 /// </summary>
 /// <param name="useEmptyMinificationSettings">
 /// Boolean to specify whether to use empty minification settings.
 /// Default value is <c>false</c>, this will use commonly accepted settings.
 /// </param>
 public MinifyXml(bool useEmptyMinificationSettings = false)
 {
     // https://github.com/Taritsyn/WebMarkupMin/wiki/XML-Minifier
     _minificationSettings = new XmlMinificationSettings(useEmptyMinificationSettings);
 }
示例#8
0
        /// <summary>
        /// Constructs instance of XML minifier
        /// </summary>
        /// <param name="settings">XML minification settings</param>
        /// <param name="logger">Logger</param>
        public XmlMinifier(XmlMinificationSettings settings = null, ILogger logger = null)
        {
            _settings = settings ?? new XmlMinificationSettings();
            _logger = logger ?? new NullLogger();
            _xmlParser = new XmlParser(new XmlParsingHandlers
            {
                XmlDeclaration = XmlDeclarationHandler,
                ProcessingInstruction = ProcessingInstructionHandler,
                Doctype = DoctypeDelegateHandler,
                Comment = CommentHandler,
                CdataSection = CdataSectionHandler,
                StartTag = StartTagHandler,
                EndTag = EndTagHandler,
                EmptyTag = EmptyTagHandler,
                Text = TextHandler,
                IgnoredFragment = IgnoredFragmentHandler
            });

            _buffer = new List<string>();
            _errors = new List<MinificationErrorInfo>();
            _currentNodeType = XmlNodeType.Unknown;
            _currentText = string.Empty;
        }