Patrick Steele's .NET Blog
Implements ICodeWithDotNet
-
Handy Extension Methods for ASP.NET MVC's UrlHelper
Mickael Chambaud posted three extension methods he created for UrlHelper: Image(), Stylesheet() and Script(). They make it pretty easy to keep your images, stylesheets and scripts organized in a single location – without the need for you to remember where they are placed. And if you need to move things around for some reason, you only have to change the extension methods.
-
Enabling Windsor Integration in MonoRail
I recently wanted to take on old MonoRail application and update it to use Windsor for dependency injection (DI). The application stated as a sort of prototype and slowing grew into a decent sized application. There's a couple of places that I want to add some unit tests and I could really benefit from DI. So I sat down to hook Windsor into the application.
-
ASP.NET MVC + MVC Contrib + Unit Testing
One of the key benefits of the MVC (Model View Controller) pattern is a separation of concerns that leads to better testability. Microsoft recognizes this and will automatically create a separate MS Test project when creating a new ASP.NET MVC solution. While this gives you a nice head start, there's room for improvement. While actions in the MVC pattern are simply methods on a class that can easily be called by MSTest (or any unit testing framework), most web applications have interactions with supporting objects such a Request (query string, form parameters, etc…), Response (cookies, content type, headers, etc…), Session, and more. In a live environment, these objects come as a result of the HTTP request being processed by IIS. In a test environment, you're isolating just your controllers and actions and you don't have IIS and an entire HTTP pipeline.
-
Know Your Environment!
This is probably one of the most embarrassing things I've admitted to in public (well, maybe not – but close). I really had to think about whether I wanted to post this. The mentor in me said "You need to post this. Others may run into this situation and this will help them." But the rest of me was saying "You can't admit to that!" The mentor in me won out and I'm posting this in the hopes it may save someone else a few hours of headaches.
-
Lansing Day of .NET 2009
Last Saturday (August 1st) was Lansing's Day of .NET. The guys organizing this did a great job and I had a really fun time. I gave my "Intro to ASP.NET MVC" presentation. I got some great questions during the presentations as well as good feedback. I did have a few questions that I wanted to follow up on:
-
LINQ2SQL: SubmitChanges() doesn't do anything?
Dear Linq2SQL,
-
Ann Arbor Give Camp 2009
I've almost recuperated from last weekend's Ann Arbor Give Camp. Almost…
-
One More Week Until Give Camp 2009
To-do lists are being checked off and the final bits of organizing are almost complete for this year's Ann Arbor Give Camp. For those attending (you did register, didn't you?), we've got our schedule posted along with a nice Q&A section that should answer most of your questions on the logistics of the event. If something isn't answered, let me know and I'll get you an answer.
-
Comparing Two Arrays
I was looking at some old code today that was checking if two byte arrays had the same data in them. It was a simple loop that compared each element. I recalled my blog post from November of last year about comparing collections/arrays in MSTest and thought, "I wonder if LINQ has something similar"?
-
LINQ: Quickly Create Dictionaries with ToDictionary
Donn Felker recently blogged about a neat little extension method in LINQ called Any(). If you simply want to know if a sequence contains any elements, many people use ".Count() > 0" which will walk the entire sequence to compute the count whereas .Any() will stop walking as soon as it finds a single element. Easy and much more efficient.