RE: Way to Lambda

One use of lambdas is to provide a method to a sub-routine that it can call if it needs something from the caller. I have implemented this pattern in a temporary caching class that I use sometimes but I think this example is more fun.

using System;
using System.Collections.Generic;
public class CowBell { }
public class BlueÖysterCult 
{
    public BlueÖysterCult()
    {
        var session = new JamSession<CowBell>();
        session.Jam(
            needs: () => session.TheCure.Count < 1000, 
            more: () => new CowBell());
    }
}
public class JamSession<T>
{
    public List<T> TheCure;
    public JamSession()
    {
        TheCure = new List<T>();
    }
    public void Jam(Func<Boolean> needs, Func<T> more)
    {
        while (needs())
        {
            TheCure.Add(more());
        }
    }
}

And if that is not a big enough of a yawn, here is a simple generic cache implementation.

    public class Cache<T> where T : class
    {
        private readonly Func<string, object> _get;
        private readonly Action<string, object> _set;
        private readonly Action<string> _clear;
        private readonly Func<string> _name;

        public Cache()
        {
            _get = (key) => HttpContext.Current.Cache[key];
            _set = (key, obj) => HttpContext.Current.Cache[key] = obj;
            _clear = (key) => HttpContext.Current.Cache.Remove(key);
            _name = () => typeof (T).FullName;
        }
        public T Item
        {
            get { return (T)_get(_name()); }
            private set
            {
                if (value == null) _clear(_name());
                else _set(_name(), value);    
            }
        }
        public T Get(Func<T> data)
        {
            return Item ?? (Item = data());
        }
        public void Clear()
        {
            Item = null;
        }
        public bool Exists()
        {
            return Item != null;
        }
    }

AppHarbor Quick Start

AppHarbor is a cloud based an online continuous integration service. It takes a commit to source code version control repository, builds it and deploys it to a host.

What this provides is fast web application deployment that includes hosted change management and site hosting.

In this example we will use a GitHub repository and it’s Windows client so that needs to be installed first.

Login to AppHarbor and create a new application.
On the application page choose the option to Configure GitHub to deploy to AppHarbor. This will let you choose to create a new repository or use an existing one.

Login to GitHub and add the repository to the Windows client. Search for the repository by name in the form of AppHubUserName/GitHubRepositoryName. Click the button to Setup In Windows and it will launch the GitHub Windows client.

In the GitHub client you can open the repository in Windows explorer and add files using any tool including creating a new ASP.NET web site there in the existing location using Visual Studio.

After creating the files return to the GitHub client, and a comment, commit the changes then publish the changes to the server. In AppHarbor on the application page you will see the commit and from there you can click the link to Go to your application to see the site hosted on the web.

Note that repositories can be shared with other GitHub Windows users with a URL like:
github-windows://openRepo/https://github.com/userName/repoName