When creating a new custom activity for Windows Workflow Foundation, you might want to define a property on your activity of type System.Type. An example of a property that does this would be the InterfaceType property of the HandleExternalEventActivity.

Of course, you'd like it to be so that you could use the very nice Type selection dialog that the HandleExternalEvent Activity has, instead of just having the user type the fully qualified name of the type, which is very error prone (not to mention very user unfriendly). Fortunately, there is a way to do this, at least with beta 2 of WF, by using the TypeBrowserEditor class defined in System.Workflow.ComponentModel.Design as the UITypeEditor for your Type property. Here's an example:

///

/// Type of the message object to expect

///

[DefaultValue(typeof(string))]

[Description("Type of the message object to expect")]

[Category("Activity")]

[Editor(typeof(System.Workflow.ComponentModel.Design.TypeBrowserEditor),

   typeof(System.Drawing.Design.UITypeEditor))]

[ValidationOption(ValidationOption.Required)]

public Type MessageType

{

   get { return _messageType; }

   set { _messageType = value; }

}

 


Tomas Restrepo

Software developer located in Colombia. Sr. PFE at Microsoft.