November 2010 Entries
I’ve just created a simple class which I thought I’d share. Account1.Balance += 10;
Account2.Balance -= 10;
In this case we might expect the second line to throw an exception if the adjustment is not permitted, but the first line has already executed. Obviously this isn’t a problem because we simply wouldn’t update the database, but sometimes you want an operation to occur in memory as an atomic operation; like this
using (var atomicOperation = new AtomicOperation(EcoSpace))
{
Account1.Balance += 10;
Account2.Balance -= 10;
atomicOperation.Commit();
}
And so that is exactly what I wrote. The class...
I needed to present the user with a list of objects from which they could select multiple items. There is a MultiSelectList class in ASP MVC so I looked into how to use that. It would seem that to use this class we need to use Html.ListBox. I think this is a poor choice because it requires the user to hold down the Control key to select additional options, and it is too easy to deselect all of your values accidentally by clicking the control accidentally without the Control key held down.
What I really wanted was something like a CheckListBox,...
I’m used to using SubVersion with Tortoise SVN plugged into Windows Explorer and Ankh SVN as my Visual Studio version control integration. With Tortoise I can rename a folder and the change will be picked up, I can add new folders and delete folders and these changes will also be detected; and because Ankh SVN has the same features as Tortoise SVN I can do all of these things in the Visual Studio solution explorer too. StarTeam doesn’t seem to do this. If I add a new folder in Windows Explorer I don’t expect my Visual Studio integration to...
Sometimes you have no control over the instantiation of your classes and therefore cannot use Unity. For this reason the BuildUp method was added to Unity in order to either call the method marked with [InjectionMethod] or to set all properties marked with [Dependency]. Unfortunately in the latest build this is broken. For some reason BuildUp searches for a suitable constructor even though the instance has already been created. In my case I have two constructors both with only 1 parameter so I get an ambiguous constructor exception. So, I created this helper method to call the InjectionMethod on...
I’ve recently been using ASP MVC 2 to develop a business application. As you may already know the ASP MVC routing system works with URLs which look like this http://localhost/Client/Details/IBM In standard ASPX apps the URL would look more like this http://localhost/Client/Details.aspx?code=IBM The first URL obviously looks much nicer than the 2nd, however it comes at a cost. What if the “code” of your object is something like “N/A” for “Not applicable”? You end up with a URL that looks like this http://localhost/AbsenceCode/Details/N/A What we really need is to have ASP...