[Stick to the top] Keep learning WfArticleIndex
Activity)
An activity is the basic unit of a workflow. Each workflow contains several activities and is executed according to certain logic. There are two types of WF: simple activity and compound activity. WF provides a set of standard activity libraries, and you can also customize the activity. All activities are inherited from activity classes. Below is a hierarchy of the most basic activities in WF:
The following is a standard activity provided by WF. I will not write anything about it. For details, refer to msdn and I will write it later.
Flow |
Execution |
Events |
Web Services |
State |
Ifelse |
Transactionscope |
Eventdriven |
Webserviceinput |
Setstate |
While |
Sequence |
Listen |
Webserviceoutput |
State |
CAG |
Compensate |
Handleexternalevent |
Webservicefault |
Stateinitialization |
Policy |
Synchronizationscope |
Eventhandlingscope |
Invokewebservice |
Statefinalization |
Replicator |
Code |
Delay |
|
|
Throw |
Parallel |
|
|
|
Suspend |
Invokeworkflow |
|
|
WCF |
Terminate |
Callexternalmethod |
|
|
Receiveactivity |
Faulthandler |
Compensatablesequence |
|
|
Sendactivity |
|
Compensatabletransaction Scope |
|
|
|
Dependencyobject)
Dependency Property is a special type of property provided by WF. It has three types of dependency properties: instance property, metadata property, and additional property.
Metadata attribute: the value of the metadata attribute must be specified during design and cannot be changed during runtime. In this way, metadata attributes cannot be bound. metadata attributes are implemented by specifying the metadata option.
Instance property: You can use activity data binding to set the value, whether at design or runtime. You can assign activitybind to this property instead of the actual value.
Additional attributes: We can attach a dependency attribute to any object inherited from dependencyobject. in other words, we can use custom attributes to expand all windows workflow activities at runtime. if the parent activity needs to append information for each sub-activity, the additional attributes will be used. the standard activity provided by WF has a typical example: conditionedactivitygroup activity. it can execute one or more sub-activities with conditions, because it appends the when condition to each sub-activity. in the workflow designer, each sub-activity of the CAG displays its own when attribute.
It is said that there are dependency attributes in WPF, but in the system. Windows namespace, WF has the same concept in system. workflow. componenmoduel, but cannot communicate with each other.
Only system. workflow. componentmodel. dependencyobject class can be used to define dependencyproperty. To define dependencyproperty, you must use system. workflow. componentmodel. dependencyproperty registers attributes statically. The following defines a dependency attribute.
Public Static Dependencyproperty nametoprintproperty = Dependencyproperty. Register ( " Nametoprint " , Typeof (System. String ), Typeof (Customactivity ));
[Descriptionattribute ( " String to be passed to the custom Activity " )]
[Designerserializationvisibilityattribute (designerserializationvisibility. Visible)]
[Browsableattribute ( True )]
Public String Nametoprint
{
Get
{
Return (String )( Base . Getvalue (customactivity. nametoprintproperty )));
}
Set
{
Base . Setvalue (customactivity. nametoprintproperty, value );
}
}
Note:
The format of static subordinate attributes and registered subordinate attribute names must be: [Name property] and [name], for example:
Eg1property = Dependencyproperty. Register ( " Eg1 " ,
Eg1property = Dependencyproperty. Register ( " Eg2 "
This dependency attribute can be bound to the workflow attributes. Of course, the activity attribute can also be bound to other activity attributes. The bound property can be a dependency property or a normal property in. net. As shown in:
You need to think thatCodeIt is very complicated. In many cases, you can use code segments, such:
Dependencyproperty event
1. The dependencyproperty event is essentially the same as the dependencyproperty subordinate property.
2. addhandler and removehandler add and remove events by using subordinate attributes.
3. Define a dependencyproperty event
Public Static Dependencyproperty becareevent = Dependencyproperty. Register ( " Becare " , Typeof (Eventhandler ), Typeof (Activity1 ));
// Define events
Public Event Eventhandler EA
{
Add
{
Base . Addhandler (activity1.becare, value );
}
Remove
{
Base . Removehandler (activity1.becare, value );
}
}
}
4. The runable code of the dependencyproperty attribute and dependencyproperty event will be reflected in the next custom activity.
Previous Article: persistence in learning WF (3): Overview of WF framework
Next article: persistence in learning WF (5): Custom Activity)