July 18, 2007
@ 06:48 AM
  1. Oct. 25, 1978: First pet goldfish died. Realized living things die. Cried for weeks.
  2. Dec. 25, 1980: Opened gift from "Santa" that I had seen in parent's closet. Realized Santa is a lie. 
  3. July 16, 2007: Couldn't get this code to compile:

  ...realized that System.Windows.DependencyProperty and System.Workflow.ComponentModel.DependencyProperty are two entirely different classes. Only System.Windows.DependencyProperty, or more precisely System.Windows.PropertyMetadata supports the nifty CoerceValue callback.

I wonder why we have two separate families of DependencyProperty related stuff? Seems really weird and poorly thought out. Kind of "Hack"-ish.

What really hurts is that there doesn't seem to be a good way to coerce custom type dependency properties in WF-land. The answer is right there in WPF's PropertyMetadata, but we can't use it in WF.

The thing I was really trying to do was have a generic iterator-like activity that contained custom activities with custom type dependency properties. Like a ForEach activity that contained a custom Activity like "LoadPortfolio" with a Dependency Property called "Client" that was a custom type. The ForEach has a DataItem property it sets to the current item it is iterating in the context of each child, but because ForEach is general purpose, the type of DataItem is System.Object.

It would be easy to coerce DataItem to "Client" (just cast or use "as"!) but there doesn't seem to be a mechanism to do this in WF, and because of the type mismatch, my workflow can't even load.

So do I make a special ForEach for each type I want to iterate over? Do I change the Client property on my LoadPortfolio activity to type System.Object?

Hopefully I'll find a way to work around this that I can live with soon.


 
Tuesday, July 31, 2007 4:51:58 AM (Pacific Standard Time, UTC-08:00)
Hey Chris,

I'm wondering how come you don't just use the "While" activity for a generic 'ForEach' type of purpose. Within the 'While' activity, you can place a 'Sequence' activity and put a bunch more stuff inside of that.

You could easily put your "custom" activities inside that 'While'-'Sequence' activity combination and do whatever you like.

Does that create a problem for you?
Monday, August 06, 2007 5:40:26 AM (Pacific Standard Time, UTC-08:00)
The while sequence would still not be able to bind to the property I wanted, with my application specific type. Also, while executes in sequence, but I want my "ForEach" to execute in paralell (i.e., there are no dependencies between the activities for each item in the sequence.)

Then again, I am new to this so may be getting it all wrong!
Chris Bilson
Comments are closed.