0

How can I use custom code (activity file not codeactivity neither activitydesginer ) as an Activity inside a Reshosted workflow designer?

I was doing the following for any activity, which I build for each ( codeactivity & activitydesginer) files, and wirte:

            new ToolboxCategory("new Toolbox")
                {                        
                   Tools=
                   {
                        new ToolboxItemWrapper(typeof(Flowchart)),
                        new ToolboxItemWrapper(typeof(SimpleWebDesigner.TEST)),

....etc

AnyHelp?

Sofy
  • 11
  • 4

1 Answers1

1

If you're talking about loading an Activity loaded from a loose xaml file, you can do this.

You have to use the the ActivityXamlServices class to Load(filename) the file at runtime. When you do this, you get the deserialized Activity instance. Of course, you must have any relevant assemblies (any assembly referenced by Activities defined in the xaml file) either loaded in the AppDomain or available for loading where the Fusion loader can find them.

Once you do this, you can create a ToolboxItemWrapper passing in activityInstance.GetType().

One thing, since the Activity xaml file is an Activity which holds other Activities, you will get the default Designer, which only shows a blank header. There is no easy way* to expand the child Activities defined in the xaml file in the designer when you drop them on the design surface.

*I believe you can construct a class that implements IActivityTemplateFactory which you can pass to the ToolboxItemWrapper which can pass the root Activity defined within your xaml file, so that when you drag/drop the item from the toolbox it will automatically add all child Activities defined in the xaml file. But I've never done this and am not sure if you can.

  • Ok, Thank you. but I put in the activity file (.xaml) file, if activity. the IF condition is ( argument1 = True )// case boolean or ( argument1 = "yes")// case string How can I pass the value for this argument? – Sofy Jul 07 '11 at 11:03
  • @Sofy: That's a completely different matter. You normally do this by providing a Dictionary which contains the values (argument1) keyed by their names, when executing the workflow. http://msdn.microsoft.com/en-us/library/dd489463.aspx –  Jul 07 '11 at 13:06