Click here to Skip to main content
13,631,574 members
Click here to Skip to main content
Articles » Web Development » ASP.NET » Samples » Downloads

Stats

40.7K views
3.1K downloads
22 bookmarked
Posted 1 Nov 2009
Licenced Apache

Combres - WebForm & MVC Client-side Resource Combine Library

, 1 Nov 2009
A .NET library which enables minification, compression, combination, and caching of JavaScript and CSS resources for ASP.NET and ASP.NET MVC web applications. Simply put, it helps your applications rank better with YSlow and PageSpeed.
Combres
trunk
Combres
API
Common
Configuration
Exceptions
Filters
Model
Properties
Resources
Libraries
EcmaScript.NET.modified.dll
Fasterflect.dll
log4net.dll
Yahoo.Yui.Compressor.dll
Samples
MvcSample
App_Data
Content
images
ui-bg_diagonals-thick_18_b81900_40x40.png
ui-bg_diagonals-thick_20_666666_40x40.png
ui-bg_flat_10_000000_40x100.png
ui-bg_glass_100_f6f6f6_1x400.png
ui-bg_glass_100_fdf5ce_1x400.png
ui-bg_glass_65_ffffff_1x400.png
ui-bg_gloss-wave_35_f6a828_500x100.png
ui-bg_highlight-soft_100_eeeeee_1x100.png
ui-bg_highlight-soft_75_ffe45c_1x100.png
ui-icons_222222_256x240.png
ui-icons_228ef1_256x240.png
ui-icons_ef8c08_256x240.png
ui-icons_ffd27a_256x240.png
ui-icons_ffffff_256x240.png
Controllers
Properties
Scripts
Views
Home
Shared
Site.Master
WebFormSample
App_Data
Content
images
ui-bg_diagonals-thick_18_b81900_40x40.png
ui-bg_diagonals-thick_20_666666_40x40.png
ui-bg_flat_10_000000_40x100.png
ui-bg_glass_100_f6f6f6_1x400.png
ui-bg_glass_100_fdf5ce_1x400.png
ui-bg_glass_65_ffffff_1x400.png
ui-bg_gloss-wave_35_f6a828_500x100.png
ui-bg_highlight-soft_100_eeeeee_1x100.png
ui-bg_highlight-soft_75_ffe45c_1x100.png
ui-icons_222222_256x240.png
ui-icons_228ef1_256x240.png
ui-icons_ef8c08_256x240.png
ui-icons_ffd27a_256x240.png
ui-icons_ffffff_256x240.png
Properties
Scripts
Combres.dll
EcmaScript.NET.modified.dll
Fasterflect.dll
log4net.dll
Yahoo.Yui.Compressor.dll
API
Common
Configuration
Exceptions
Filters
Model
Properties
Resources
Samples
MvcSample
App_Data
Content
images
ui-bg_diagonals-thick_18_b81900_40x40.png
ui-bg_diagonals-thick_20_666666_40x40.png
ui-bg_flat_10_000000_40x100.png
ui-bg_glass_100_f6f6f6_1x400.png
ui-bg_glass_100_fdf5ce_1x400.png
ui-bg_glass_65_ffffff_1x400.png
ui-bg_gloss-wave_35_f6a828_500x100.png
ui-bg_highlight-soft_100_eeeeee_1x100.png
ui-bg_highlight-soft_75_ffe45c_1x100.png
ui-icons_222222_256x240.png
ui-icons_228ef1_256x240.png
ui-icons_ef8c08_256x240.png
ui-icons_ffd27a_256x240.png
ui-icons_ffffff_256x240.png
Controllers
Properties
Scripts
Views
Home
Shared
Site.Master
WebFormSample
App_Data
Content
images
ui-bg_diagonals-thick_18_b81900_40x40.png
ui-bg_diagonals-thick_20_666666_40x40.png
ui-bg_flat_10_000000_40x100.png
ui-bg_glass_100_f6f6f6_1x400.png
ui-bg_glass_100_fdf5ce_1x400.png
ui-bg_glass_65_ffffff_1x400.png
ui-bg_gloss-wave_35_f6a828_500x100.png
ui-bg_highlight-soft_100_eeeeee_1x100.png
ui-bg_highlight-soft_75_ffe45c_1x100.png
ui-icons_222222_256x240.png
ui-icons_228ef1_256x240.png
ui-icons_ef8c08_256x240.png
ui-icons_ffd27a_256x240.png
ui-icons_ffffff_256x240.png
Properties
Scripts
using System;
using System.Web;
using System.Web.Caching;
using System.Xml.Schema;

namespace Combres
{
    internal static class Configuration
    {
        private static readonly ConfigSectionSetting Config = ConfigSectionSetting.Create();
        private static readonly string CacheKey = string.Concat(typeof(Configuration).FullName,
            ".", DateTime.Now);

        /// <summary>
        /// Creates an instance of <see cref="Settings"/> based on the XML definition file.
        /// The result will be cached as long as the XML definition file isn't change.  If the 
        /// file is changed, a new instance will be created upon the next request.
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        /// <exception cref="ArgumentNullException">If <paramref name="context"/> is null</exception>
        /// <exception cref="XmlSchemaException">If there is any validation error in the 
        /// XML definition file.</exception>
        internal static Settings GetSettings(HttpContext context)
        {
            if (context == null)
                throw new ArgumentNullException("context");

            var settings = context.Cache[CacheKey] as Settings;
            if (settings == null)
            {
                /*
                 * The Cache object is thread-safe thus there won't be any data corruption.
                 * The code is not protected against multiple writes although due to the 
                 * huge amount of reads and limited number of writes, this no-lock approach 
                 * is likely to be more efficient than the use of lock.
                 */
                var filePath = context.Server.MapPath(Config.DefinitionUrl);
                settings = new ConfigReader().Read(filePath);   
                context.Cache.Insert(CacheKey, settings, new CacheDependency(filePath));
            }
            return settings;
        }

    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Apache License, Version 2.0

Share

About the Author

Buu Nguyen
Chief Technology Officer KMS Technology
Vietnam Vietnam
You can visit Buu's blog at http://www.buunguyen.net/blog to read about his thoughts on software development.

You may also be interested in...

Permalink | Advertise | Privacy | Cookies | Terms of Use | Mobile
Web02-2016 | 2.8.180712.1 | Last Updated 2 Nov 2009
Article Copyright 2009 by Buu Nguyen
Everything else Copyright © CodeProject, 1999-2018
Layout: fixed | fluid