WebMarkupMin options
Inheritance: WebMarkupMin.AspNet.Common.WebMarkupMinConfigurationBase
示例#1
0
        /// <summary>
        /// Constructs a instance of WebMarkupMin middleware
        /// </summary>
        /// <param name="next">The next middleware in the pipeline</param>
        /// <param name="options">WebMarkupMin options</param>
        /// <param name="services">The list of services</param>
        public WebMarkupMinMiddleware(RequestDelegate next,
                                      IOptions <WebMarkupMinOptions> options,
                                      IServiceProvider services)
        {
            if (next == null)
            {
                throw new ArgumentNullException("next");
            }

            if (options == null)
            {
                throw new ArgumentNullException("options");
            }

            if (services == null)
            {
                throw new ArgumentNullException("services");
            }

            _next    = next;
            _options = options.Value;

            var minificationManagers = new List <IMarkupMinificationManager>();

            var htmlMinificationManager = services.GetService <IHtmlMinificationManager>();

            if (htmlMinificationManager != null)
            {
                minificationManagers.Add(htmlMinificationManager);
            }

            var xhtmlMinificationManager = services.GetService <IXhtmlMinificationManager>();

            if (xhtmlMinificationManager != null)
            {
                minificationManagers.Add(xhtmlMinificationManager);
            }

            var xmlMinificationManager = services.GetService <IXmlMinificationManager>();

            if (xmlMinificationManager != null)
            {
                minificationManagers.Add(xmlMinificationManager);
            }

            _minificationManagers = minificationManagers;

            var compressionManager = services.GetService <IHttpCompressionManager>();

            if (compressionManager != null)
            {
                _compressionManager = compressionManager;
            }
        }
        /// <summary>
        /// Checks whether the HTTP compression is enabled
        /// </summary>
        /// <param name="options">WebMarkupMin options</param>
        /// <returns>Result of check (true - compression is enabled; false - compression is disabled)</returns>
        public static bool IsCompressionEnabled(this WebMarkupMinOptions options)
        {
            bool isCompressionEnabled = false;

            if (!options.DisableCompression)
            {
                isCompressionEnabled = !options.HostingEnvironment.IsDevelopment() ||
                                       options.AllowCompressionInDevelopmentEnvironment;
            }

            return(isCompressionEnabled);
        }
		/// <summary>
		/// Constructs a instance of WebMarkupMin middleware
		/// </summary>
		/// <param name="next">The next middleware in the pipeline</param>
		/// <param name="options">WebMarkupMin options</param>
		/// <param name="services">The list of services</param>
		public WebMarkupMinMiddleware(RequestDelegate next,
			IOptions<WebMarkupMinOptions> options,
			IServiceProvider services)
		{
			if (next == null)
			{
				throw new ArgumentNullException("next");
			}

			if (options == null)
			{
				throw new ArgumentNullException("options");
			}

			if (services == null)
			{
				throw new ArgumentNullException("services");
			}

			_next = next;
			_options = options.Value;

			var minificationManagers = new List<IMarkupMinificationManager>();

			var htmlMinificationManager = services.GetService<IHtmlMinificationManager>();
			if (htmlMinificationManager != null)
			{
				minificationManagers.Add(htmlMinificationManager);
			}

			var xhtmlMinificationManager = services.GetService<IXhtmlMinificationManager>();
			if (xhtmlMinificationManager != null)
			{
				minificationManagers.Add(xhtmlMinificationManager);
			}

			var xmlMinificationManager = services.GetService<IXmlMinificationManager>();
			if (xmlMinificationManager != null)
			{
				minificationManagers.Add(xmlMinificationManager);
			}

			_minificationManagers = minificationManagers;

			var compressionManager = services.GetService<IHttpCompressionManager>();
			if (compressionManager != null)
			{
				_compressionManager = compressionManager;
			}
		}