Series Directory: WF Series 3 Out-of-the-Box Activities topic directory
Code Activity is one of the most frequently used activities in WF development. It is easy to do. It is to execute one or several codes and trigger a Handlers when this behavior is being executed: executeCode.
1. Simple Code Activity Application
* Check this Code.
Public sealed partial class Workflow1: SequentialWorkflowActivity
{
Public Dictionary <int, string> nameList = new Dictionary <int, string> ();
Public string BadFriend;
Public string CloseFriend;
Public Workflow1 ()
{
InitializeComponent ();
NameList. Add (1, "Andy ");
NameList. Add (2, "Jacky ");
NameList. Add (3, "FUChen ");
NameList. Add (4, "Brian ");
}
Private void codeactivityappsexecutecode (object sender, EventArgs e)
{
Console. WriteLine ("Enter Name :");
String friend = Console. ReadLine ();
Console. WriteLine ("Enter Bad Friend :");
This. BadFriend = Console. ReadLine ();
Console. WriteLine ("Enter Close Friend :");
This. CloseFriend = Console. ReadLine ();
}
}
2. Custom Attributes of Code Activity custom applications
Create an ActivityLibrary. After creation, select System. Workflow. ComponentModel. Activity as BaseClass.
To customize attributes, you must create fewer attributes.
Create attributes:
In earlier versions, you can visually create Propertys. Now, the Code Snippets method has been used to create Custom Property.
Specific Operation: Ctrl + k Ctrl + X, select workflow and DependencyProperty-Property to generate code
In addition, adding ToolboxBitmap to the top of the class can change the display icon of CodeActivty. comrades who like custom icons must like this attribute.
[ToolboxBitmap (typeof (CodeActivityClass), "XXX.png")]
What is the role of this attribute? It can be edited.
[Editor (typeof (MultilineStringEditor), typeof (UITypeEditor)]
Finally:
Figure 1And Code are all customized.
Of course, other operations on Custom Attributes are as follows:Figure 2, Specific usage. If you are interested, you can study it.
Figure 1 Figure 2