22 January 2007

Reflector's addins

I've been told of two addins for this great tool Reflector.

One is the File Disassembler addin, which you can use to generate code, in any language, from any assembly. This maybe useful for translating from one language to another, or to view the code in Visual Studio rather than in Reflector, but the truth is I haven't got the opportunity to need it yet.

The other addin, which I do use a lot, is the Code Metrics Addin. This one computes several code quality metrics of the assembly, such as the number of members of a class, the cyclomatic complexity, or the distance to the main sequence.

Since the link for downloading seems to be broken, I've upload it here.

Blogging tools

I've recently discover two handy tools for blogging. The first one is the Windows Live Writer. It is a little more friendly than the Blogger's editor, besides the advantage of allowing you to write offline. I have no problems in writing here to Blogger, despite of not being able to upload images.

The other tool I started using last week is the Google Reader. It is really cool, like all other google stuff. It has the drawback of you having to request the page, but you can access it from any computer.

More on WF: Getting Started

Continuing with the research on Workflow Foundation, here goes just a couple of things to get started with.

1- Quickly create your first sequence workflow

[See my previous post about the requirements for developing .Net framework 3 features.]

I am not going to put many details here, but to create your first workflow you need to select one of the workflow project templates in Visual Studio 2005. Just to start select the Sequential Workflow Console Application template. This generates a project with the references to the WF assemblies, the workflow itself and a test program.

By clicking on the workflow class the workflow is shown in the designer. Here is where you can drag activities from the toolbox. For example drag a CodeActivity. In the CodeActivity ExecuteCode property, type a method's name and press enter. VS will generate the method stub for you. Just write hello world to console there. Pressing the "view code" tab, the partial class with the workflow code (wfl properties, event_handlers, methods, etc) appears. You can see that the workflow inherits from SequentialWorkflowActivity.

So far we have the workflow defined with a set of activities. What we need now is to host the workflow and execute it. The generated program shows us how to do it:

using(WorkflowRuntime workflowRuntime = new WorkflowRuntime()) {


WorkflowInstance instance = workflowRuntime.CreateWorkflow(typeof(WorkflowConsoleApplication1.Workflow1));




So, just press F5 and see the greeting message!

2- Get a feel of the Pre-build Activities

Some of the pre-build activities I have been experiencing with:

  • CallExternalMethod
  • Code
  • Delay
  • IfElse
  • Listen
  • Sequence
  • HandleExternalEvent

They are more or less self explained...I only want to mention one thing that may be a constraint in some circumstances:

The CallExternalMethod activity needs the following properties to execute:

  • InterfaceType
  • MethodName
  • Parameters

and the HandleExternalEvent similar properties:

  • InterfaceType
  • EventName
  • Parameters

In both cases the InterfaceType must be an Interface decorated with the ExternalDataExchange attribute, only this type of interfaces will be listed by the object browser. So the presence of that attribute is what I think may be a restriction as you can't use just any already built assembly.

3- Pass data to the WF:

There are two general approaches for receiving data into a workflow when it is started. They are Parameters and Events. With parameters, a list of parameter names and types are defined with the workflow. These parameter values are passed in by a host when it starts a new instance of the workflow type. With events, workflow authors add an activity that receives an event and data associated with the event. Events are generally specific to the host and custom activities that have been designed to handle the event.

The parameters can be passed in the CreateWorkflow method as shown here:

using(WorkflowRuntime workflowRuntime = new WorkflowRuntime()) {


Dictionary<string, object> parameters = new Dictionary<string, object>();
parameters.Add("FirstName", "Tom");
parameters.Add("LastName", "Sawyer");

WorkflowInstance instance = wr.CreateWorkflow(typeof(HelloWorldWorkflow.Workflow1), parameters);



4- Make use of Conditions

A rule condition is a condition statement that is created in a dialog and stored as XML with the workflow. It can include predicates that compare workflow state and Boolean algebra combining multiple predicates. The conditions can be used in various activities including IfElse, While, ConditionedActivityGroup, and Replicator.

Take for example the IfElse activity. A condition can be set to one or both of its branches using the activity's properties. You can specify a CodeCondition or a DeclarativeCondition. In the first case you just enter the method's name. When you press enter the condition handler will be generated and shown in the code window. Put your logic in there, for instance:

public void If_Condition(object sender, ConditionalEventArgs e){

e.Result = this.reviewArgs.Review.Approved;


When using the DeclarativeCondition, you can use the Condition Editor to create it. You can access the workflow properties by intellisense.

16 January 2007

My turn in the blog-tag game!

As I’ve been tagged by my boyfriend, I suppose it’s my turn in this blogger’s game to play. So, here goes 5 things some people may don’t know about me:

  1. I went to live on my own a few months ago, to a very cute apartment in Almagro, 5 blocks from my parents. It can’t actually be said a live “alone” since I have this eternal, and of course very welcome and lovely visit, my boyfriend.

  2. I have a degree in Electronic Engineer from the University of Buenos Aires, but I’ve never worked as such. I have always worked as a software developer, nowadays in a great software company: Lagash Systems.

  3. I have always like Maths. I kind of have it in the blood since both my parents are mathematicians. I’ve always teach math, first giving particular lessons and since many years now at the university, where I still teach “Algebra II” and used to teach “Probability and Statistics” too.

  4. When I was young I studied music for many years (since I was 6 till 15) at the National Conservatory. I played piano and flout. Unfortunately I have a very bad memory and can’t remember a single piece of music. But I can still play if I’m in front of the sheet. I play mostly classic, despite for some Queen songs I learned when I was a teen and a great fan of them.

  5. In my free time? I like to walk, dance, and go biking a lot. I try to go by feet everywhere whenever it is possible. I don’t like to stay much inside, I prefer to take some air. I really enjoy going anywhere with my boyfriend, going to the country house on Sundays with the family and hanging out with my friends.

Now it's time to tag another 5 people: RodolfoF, Zaiden, PabloC , Cyn and Pede.