XML minifier
Inheritance: IMarkupMinifier
Beispiel #1
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);
        }
Beispiel #2
0
        public IEnumerable<IDocument> Execute(IReadOnlyList<IDocument> inputs, IExecutionContext context)
        {
            XmlMinifier minifier = new XmlMinifier(_minificationSettings);

            return Minify(inputs, context, minifier.Minify, "XML");
        }
        /// <summary>
        /// Gets a instance of inner XML minifier
        /// </summary>
        /// <returns>Instance of inner XML minifier</returns>
        private XmlMinifier GetInnerXmlMinifierInstance()
        {
            lock (_innerXmlMinifierInstanceSynchronizer)
            {
                if (_innerXmlMinifier == null)
                {
                    _innerXmlMinifier = new XmlMinifier(new XmlMinificationSettings
                    {
                        MinifyWhitespace = (_settings.WhitespaceMinificationMode != WhitespaceMinificationMode.None),
                        RemoveXmlComments = _settings.RemoveHtmlComments,
                        RenderEmptyTagsWithSpace = (_settings.EmptyTagRenderMode != HtmlEmptyTagRenderMode.Slash)
                    });
                }

                return _innerXmlMinifier;
            }
        }
        /// <summary>
        /// Gets a instance of inner XML minifier
        /// </summary>
        /// <returns>Instance of inner XML minifier</returns>
        private XmlMinifier GetInnerXmlMinifierInstance()
        {
            if (_innerXmlMinifierInitializedFlag.Set())
            {
                _innerXmlMinifier = new XmlMinifier(new XmlMinificationSettings
                {
                    MinifyWhitespace = _settings.WhitespaceMinificationMode != WhitespaceMinificationMode.None,
                    RemoveXmlComments = _settings.RemoveHtmlComments,
                    RenderEmptyTagsWithSpace = _settings.EmptyTagRenderMode != HtmlEmptyTagRenderMode.Slash
                });
            }

            return _innerXmlMinifier;
        }