C#

C#

Code and slides for Dev208 at Tech Ed NZ

Here are the slides and demos for the Tech Ed NZ talk Stef and I did on Intro to Workflow 4. It includes the Approval Sample we didn’t manage to fit in. P.S. I know this blog sucks in IE, working on a fix when I get some time. DEV208-GettingStartedWithWorkflow.pptx Intro To WF Demos.zip

Workflow 4: Human based workflows with an Email Approval Sample

One of the questions that a lot of people ask about workflow 4 is how to integrate manual tasks into the workflow process so that humans can be involved and interact with the workflow process. After all, what use is a stateful, long running service if no humans are involved? All of the activities that ship with workflow 4 and many of the samples provided only really cover programmatic activities but what about user interaction, I mean WF4 does not even ship with an email activity. The purpose of this post is to introduce the concept of a manual...

Unit Test Workflow 4 Activities : Dependency Injection

At first glance unit testing workflow activities with dependency injection seems like a no-brainer. For example consider the following activity using constructor-based dependency injection. public class SendEmail : CodeActivity { private readonly IEmailClient emailClient; public SendEmail() : this(new EmailClient()) {} public SendEmail(IEmailClient emailClient) { this.emailClient = emailClient; } public InArgument<string> To { get; set; } public InArgument<string> From { get; set; } public InArgument<string> Subject { get; set; } ...

Unit Testing Workflow 4 Activities : The TestContext Tracking Participant

I’m a big believer in using TestContext in MSTest or Console.WriteLine, Debug.WriteLine etc in your favourite Unit Testing framework to give context to passed or failed tests. Especially if you do CI and have only the test results to look at from the build server to try to understand why a build went wrong. Taking this into account I use a TestContext Tracking Participant to get more visibility into my workflow unit tests. This enables me to see what tracking records have been raised against my invoked workflows. In only a few lines of code you can quickly enable...

Unit Testing Workflow 4 Activities : Basics

Unit testing workflows became a lot easier in WF4. The basic approach is the same as for normal code classes except for a few differences which we will cover in the posts in this series. Lets start off with a simple code activity which will return the time in a given city. public class GetCityTime : CodeActivity<DateTime>{ [RequiredArgument] public InArgument<string> City { get; set; } public InArgument<DateTime> LocalTime { get; set; } protected override DateTime Execute(CodeActivityContext context) { string...

NHibernate - Custom User Types and Collections

NHibernate is an extremely powerful ORM but sometimes its quite difficult to find information on how to do certain things and why other things are the way they are. Recently I've been working on generating NHibernate mapping files and a domain model with its classes using Visual Studio DSL tools. Below are some of the difficulties I came across and their solutions. Mapping Enums to string database representations Sometimes you have a database schema which requires you to provide things like "M" for male and "F" for female. It does not make sense to force your users to use a string for...