WF Series 3-Code Activity topics

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.