Twitter Updates for 2009-06-25

June 25th, 2009

Powered by Twitter Tools.

Twitter Updates for 2009-06-21

June 21st, 2009
  • [pinmame] http://bit.ly/269pZ M. Scott Ford - Added utility to list all of the game names and their indexes in the driver list. #
  • [pinmame] http://bit.ly/16OUiF M. Scott Ford - Refactored reusable class definitions into separate files. #

Powered by Twitter Tools.

Twitter Updates for 2009-06-18

June 18th, 2009
  • I found a bug in iPhone OS 3. MobileMe photo libraries take up space but they don’t display. #

Powered by Twitter Tools.

Working with C# Anonymous objects

June 8th, 2009

Anonymous objects in C# are very handy, especially given the way they are supported by the ASP.NET MVC framework.

I recently ran into a case where I wanted to interact with an anonymous object. Specifically, I was testing the data that I provided a JsonResult. I handed the JsonResult a pretty complicated anonymous object with several layers of nesting. This is a great use of anonymous objects because in code they look a lot like JSON. So, how do I make sure that the JsonResult is getting the correct data? The answer is reflection. But like with all things, there is a hard way and an easy way.

First the hard way.

var example = new {
  stringData = "string data",
  integerData = 12,
  booleanData = true
}

Given the block of code above, if we want to retrieve one of the values from the example instance we have to do the following.

string value = (string) example.GetType().
  InvokeMember(
    "stringData",
    BindingFlags.GetProperty,
    null,
    example,
    new object[] { });

Replace “stringData” with the name of any of the fields and there you go. The trouble is that this block of code is seven kinds of ugly (yes, I counted) and it is not the kind of thing that you want to type over and over. Wouldn’t it be nice if there was an easier way?

What if we use the following extension class. Also available as a gist on my github account.

static class ObjectExtensions
{
    public static T Property<t>(this object target, string name)
    {
        return (T)target.GetType().InvokeMember(
            name,
            BindingFlags.GetProperty,
            null,
            target,
            new object[] { });
    }
}

Now we can access fields from our sample class by writing the following code.

string value = example.Property<string>("stringData");
int otherValue = example.Property<int>("integerData");
bool yetAnother = example.Property<bool>("booleanData");

I think that this looks much better. I hope this helps you as much as it has helped me.

Twitter Updates for 2009-06-05

June 5th, 2009
  • Pinmame build and links as a library. I can even call it from Ruby using FFI. And, I can do all of that on Mac OS X and Windows. #
  • [pinmame] http://bit.ly/agUKb M. Scott Ford - Initial readme with build instructions for Windows. #
  • [pinmame] http://bit.ly/xHxzD mscottford - Updated some formatting. #
  • [pinmame] http://bit.ly/yRsCK M. Scott Ford - Added sections to cover getting the source. #
  • I added a post commit hook on github to post a tweet whenever I make a change. Hopefully, this wont annoy anyone. #
  • [pinmame] http://bit.ly/1650po mscottford - Adjusting formatting #

Powered by Twitter Tools.

Twitter Updates for 2009-06-03

June 3rd, 2009
  • Working on calling Pinmame methods using Ruby FFI. What fun! #
  • Does anyone else think that makefiles are really ugly? #
  • Ruby FFI will not work if you do not link your library correctly. For a shared library newbie, this is frustrating. #

Powered by Twitter Tools.

Twitter Updates for 2009-06-01

June 1st, 2009
  • Up is a very good movie. #

Powered by Twitter Tools.

Generating an ASP.NET MVC Menu from a SiteMap

May 27th, 2009

I needed an MVC helper method that generated the same markup that the WebForms Menu control does. I am not sure that it is 100% complete, but you can take a look at my first cut. I welcome any improvements or suggestions.

Twitter Updates for 2009-05-19

May 19th, 2009
  • Working on bending PinMame source code to my will. #
  • Silverstein’s a Shipwreck in the Sand is great to code to. #

Powered by Twitter Tools.

Twitter Updates for 2009-05-07

May 7th, 2009

Powered by Twitter Tools.

Twitter Updates for 2009-05-01

May 1st, 2009
  • The lego store is awesome! #

Powered by Twitter Tools.

Twitter Updates for 2009-04-28

April 28th, 2009
  • @bijou628 I always liked your hair straight. But congratulations. #

Powered by Twitter Tools.

Storing Cucumber scenarios inside TFS

April 23rd, 2009

Ever since seeing it demo at Agile 2008, I have fallen in love with cucumber. Yesterday, I posted the source code for CucumberTFS. Read on for more information about what it does.

I have been trying to introduce some Behavior Driven Development to the project that I am working on. We recently received a large batch of requirements/stories. Our goal was to develop a better way to communicate functionality with our testing team. I suggested using the cucumber given, when, then format to describe all of our scenarios.

We stored these scenarios in our Team Foundation Server (TFS) instance. This lets us track code changes against the scenarios, assign them to different people and anything else that can be done with a TFS work item. I got the idea to retrieve the scenarios from TFS and format them so that they could be run through cucumber. Enter CucumberTFS.

CucumberTFS’s first iteration attempted to wrap the call to cucumber directly. Given the problems I had with redirecting cucumber’s output so that it appeared to come from CucumberTFS, I decided to modify the tool to just generate a single feature file that contains the contents of all the scenarios in TFS.

The tool still needs some work before it can be used by the masses. I want to create a binary release with an installer, for example. And there needs to be more control over the name of the file that is generated and more control over the set of TFS work items that are retrieved.

So, if you are using TFS and want to integrate it with cucumber, then check out CucumberTFS. Head over to github, fork the project and make your own changes.

Twitter Updates for 2009-04-22

April 22nd, 2009
  • With all the of based tablets around the office, I really want Apple to cone out with a tablet Mac. #

Powered by Twitter Tools.

Twitter Updates for 2009-04-21

April 21st, 2009
  • I hate sitting in traffic. #

Powered by Twitter Tools.

Twitter Updates for 2009-03-28

March 28th, 2009
  • Ugh. Ein has at least 2 ticks on her front paws. This is going to be a fun evening. #
  • Ticks are off. Now to try to identify them. #
  • Fun filled day of smashing up plaster walls and putting up trim starts in the morning. After a drive to Roanoke, that is. Time to sleep now. #
  • I finally decided to reciprocate, and follow the people that are following me. I wonder what took me so long to do so? Just an ass, I guess. #
  • Notice that the previous two tweets were the exact maximum length that is allowed. I did that on purpose. It is harder than you might think. #

Powered by Twitter Tools.

Twitter Updates for 2009-03-22

March 22nd, 2009
  • Outside the hospital, patients line up in wheelchairs, smoking cigaretts. #

Powered by Twitter Tools.

Twitter Updates for 2009-02-25

February 25th, 2009
  • Term of the week, “clipboard inheritance”. #

Powered by Twitter Tools.

Twitter Updates for 2009-02-20

February 20th, 2009
  • This Subway does not smell like one. #

Powered by Twitter Tools.

Twitter Updates for 2009-02-17

February 17th, 2009
  • I dislike it when regions are over used. #
  • What do you mean your tests don’t all pass. #

Powered by Twitter Tools.