Extensions For IEnumerable<T> Of Custom Classes

Imagine a scenario in which you have a class called ‘Order’ and each order has a collection of ‘LineItem’. You have a collection of Order objects and want to get all of the LineItem objects for the Order collection. You could easily do this using lambda expressions and Linq. But if this functionality is commonly needed, you might find yourself repeating your lambda expressions in several places. The real problem is that you don’t have a good place to encapsulate that logic because you are always dealing with the IEnumerable rather than the order class....

September 23, 2009 · Joshua Marble

Reading Command Line Arguments

If you write very many command line utilities, you have likely had to read command line arguments many times. Since this is very much the same thing every time, it seems like a waste to write rigid and app-specific arg parsing to each program. Instead, I have created some classes to read argument arrays and turn them into something more usable. I have published these classes in a Github Gist. The first comment on the Gist describes how it works and has usage examples....

September 11, 2009 · Joshua Marble

Action.Try() Extension Method

I read an article by John Teage on the Los Techies blog that gave me an idea. The article was about a method he used to wrap an action in a Try/Catch block for testing purposes. This seems like a handy method in some cases, but having a method means you have to be in that scope for the method to be accessible or it has to be a globally shared method....

August 27, 2009 · Joshua Marble

To Delete Or Not To Delete

One of the decisions I regularly face when dealing with database data is whether to delete rows or mark them as deleted. On the one hand, the organized side of me really despises the idea of having old “deleted” records hanging around clogging up my queries. But, on the other hand, if you have the record there and for some reason determine that you need it back, it’s so nice to be able to just flip a flag and undo the delete....

August 4, 2009 · Joshua Marble

Visual Studio Keyboard Shortcut Conflict In Windows 7

Many of my codevelopers at work have been using Windows 7 for many months now. Being heavily reliant on keyboard shortcuts in Visual Studio, one of the first things I noticed was that the shortcut to remove all breakpoints (Ctrl+Shift+F9) would not work. It turns out that Windows 7 uses that key combination to toggle Windows Aero on and off. This wasn’t immediately apparent to me since at the time my Aero effects were not working, so I saw no effect....

July 27, 2009 · Joshua Marble

The Birth of CODEcisions

I’ve always liked websites that are creative in their combination of words. While thinking about all of the decisions I face every day at work, I came up with the idea of combining “code” and “decisions”. I’ve been wanting to get back into hosting my own website and blog, so I decided to go ahead and start back into it. I also am doing this partly in hopes that I would become more active in my posting....

July 27, 2009 · Joshua Marble

ToolTip AutoPopDelay Failure

Most things in Microsoft’s .Net Framework are pretty intuitive and function as expected, but every so often you run across something that is just plain stupid. I’ve run across multiple problems with tooltips before, including a nasty one in the 1.1 framework in which the tooltip would not redisplay after it timed out and hid. But, alas, this is not what I’m talking about today. Today I want to talk about the frustrating nature of ToolTips and hiding their popup display after five seconds....

April 15, 2009 · Joshua Marble

BlogEngine.Net 1.5 Release Candidate

I read Al Nyveldt’s post that a BlogEngine.Net 1.5 Release Candidate is available and immediately thought to download it and try it. Since my blog is very low traffic and not critical, I had no concerns about trying out the new version. I followed Al’s basic instructions for upgrading to 1.4.5 and backed up my entire blog before wiping it clean and copying over the new files. Then I simply copied back my App_Data folder and all was well …....

April 7, 2009 · Joshua Marble

NullReferenceException Using WCF

I was writing some WCF stub code creating web services and came across a strange NullReferenceException. I could tell from the call stack that it was something to do with the serialization, but couldn’t determine much else. Since it’s coming from the service side, I had real trouble tracking it down. I ended up having to brute force attack it by commenting code until the problem disappeared and then trying to figure it out....

March 26, 2009 · Joshua Marble

Learning Lambdas - Tips and Tricks

Anyone who spends much time looking at lambda expressions quickly realizes that they rock and are very clean and useful. I find myself using simple ones every day, but I thought I’d lay out some quick tips for anyone that shares my fondness of lambdas. If you’ve never learned about lambdas, hopefully this will help you get started. Introduction Lambda expressions are nothing more than a shorthand syntax for delegates. Anything that passes a Func<>, Predicate<>, Action<>, or any other delegate can use a lambda for a clean implementation....

February 12, 2009 · Joshua Marble