posted on Wednesday, January 30, 2008 6:25 PM |

image My little airplane coding project is officially complete.  I think I got almost any edge case covered too that someone may run into. 

I can't post the source currently since I'm 30,000 feet in the air, however I'm going to aim by this weekend to get this new and improved version up and going.

Cool Stuff in v2:

  • It is all XML based, if you update your XML file, there is a file cache dependency that destroy the cache and use the new XML file.  In addition, the cache will time out after 1 hour.  Almost everything in it can be altered, a few things I did in the code behind, however I know they can be extracted out. 
  • The source will also do some neat stuff like verify the file is on the server.  I got this idea from Joe Healy's web site.
  • Everything renders the same in FireFox and in Internet Explorer too.  Before this wasn't case.  For traffic that goes to my site at a minimum, I do have about a 25% FireFox user base so I need to be sure they are supported.
  • Zero hacks for IE or Firefox to do this too.
  • I no longer use the Yahoo CSS file.  Andy Konkol has a sweet way of doing div based layouts that work pretty nice by calculating a fixed width then translating it to percentages.
  • Everything should be with XHTML strict and CSS 2.0 valid (haven't tested due to the being in an airplane issue)

Things I still need to do on it and nice to haves:

  • Create PLC's XML file
  • Do Coding4Fun write up
  • Figure out how to do DateTimes in XML.
  • Figure out to do paging.  If you have 100 projects, right now it will show all 100.  I was thinking about LINQ but right now my web server doesn't have 3.5 extensions.
  • Add in the LightBox JavaScript library for showing pictures.
  • Maybe add in some scriptaculous animation effects.

And lets view some source code from the global.asax.cs file to check out how I actually did the caching.

public class Global : HttpApplication
{
    private static readonly string fileName = "portfolio.xml";
    protected void Application_Start(object sender, EventArgs e)
    {
        SetInCachePortfolio(Context.Cache, Context.Server);
    }

    public static Portfolio GetPortfolio(Cache cache, HttpServerUtility server)
    {
        return (cache[fileName] == null) ? SetInCachePortfolio(cache, server) : (Portfolio)cache[fileName];
    }

    private static Portfolio SetInCachePortfolio(Cache cache, HttpServerUtility server)
    {
        Portfolio portfolio = Portfolio.Load(server.MapPath(fileName));
        cache.Insert(fileName, portfolio, new CacheDependency(server.MapPath(fileName)), DateTime.Now.AddHours(1), Cache.NoSlidingExpiration);

        return portfolio;
    }
}
Tags [ Parts Building Drunktender ]

Your Comments.

No comments posted yet.

Post Comment
Title *
Name *
Email
Url
Comment *  
Please add 8 and 3 and type the answer here: