Rory Primrose

Learn from my mistakes, you don't have time to make them yourself

View project on GitHub

WF rules and bitwise OR

I have been doing some WF development this morning and came across something interesting. I had a PolicyActivity in which I was trying to assign a bitwise enum value on an object instance. The rules editor gave be an error saying that I couldn’t use a bitwise OR operation on the types of operands I was using. It seems to me that CodeDom doesn’t correctly parse bitwise OR.

From what I have googled this morning, is looks like the WF rules engine is supposed to support it. I wasn’t however able to find any code examples or screenshots of where people have successfully implemented bitwise OR. So at this stage it looks like it is just documented, not actually used.

My workaround was to modify the enum to include a definition of the bitwise value that I require so that the operator isn’t in the rule definition. While this covers this particular scenario, what happens when the enum that I need to use is defined in an assembly that I don’t control?
Read More

Are singletons evil?

This is a very well written post from one of the Readify boys about the overuse of the Singleton pattern. Food for thought. I should look at whether the places I have used singletons is appropriate.

Read More

PC vs Mac

It seems like the blogsphere is getting very busy of late with PC vs Mac (or Mac vs PC, whatever your pleasure) arguments, adverts and mud-slinging. It reminds me of the following video which I originally got via email about three or four years ago.

Classic.

Read More

Frozen Five - www.frozenfive.org

As my wife and I were traveling through New Zealand last year, we were fortunate enough to met a great Swedish couple (Anna-Lisa and Mats) who we were able to travel with for a few days. On the 29th of March, Mats is going to start a Svalbard Skiing Expedition with a group of other geoscience students from around the world.

As I am in drought ridden Australia with dead grass all around my house, city and state, I find this absolutely fascinating. Anyway, check out their site and blog.

Read More

Wizard framework RC released

I have been working on a winforms wizard framework for a while when I get the chance. My aim with this project is to be able to create a reusable framework for wizard style dialogs and pages for the 2.0 .Net framework.

The first RC version of my WizardUI has been released on CodePlex. I would appreciate any comments. You can find the release here.

Read More

Be careful of code clean-up's when you have WF projects

I am really enjoying using WCF and WF in my development. While playing with the new toys can be frustrating at times, it is a whole lot of fun. There are a few gotchas though. The one I want to highlight here is the “Find All References” support in the IDE. Here is a scenario that can bite you.

Let’s say that I am using PolicyActivities to do pre and post condition validation. I may also be using them to change data in the workflow based on rules. For example, I might need to do some business to data object mapping. To neatly achieve this conversion while avoiding a CodeActivity, I can have a rule in the PolicyActivity that calls a static method on a converter class. Now that my solution is created, I want to clean up the code to make sure I don’t have redundant methods.

In order to check if a method is being used, I would normally have used the find all references feature to see if the method is being used anywhere, but here’s the kicker. This feature (from what I can guess) only looks at code that will be compiled down to IL. This will not work when the method exists in a rules file because the rules file is simply compiled as an embedded resource.

When you have WF projects included in your solution, run a text search for the method, searching all files in the solution (not just *.cs files). Oh, and always re-run your tests after you can any code.

Read More