Datasheet

Chapter 1: Work ow Programming Principles
16
Developing Custom Composite Activities
A composite activity or logical program statement, just like a C# composite program statement such as
“ { }, ” “ for, ” “ while, ” and so on, is a logical program statement that contains other logical program
statements or activities. In general, there are two types of composite activities. The first type includes flow
control constructs such as “ { }, ” “ for, ” and “ while. ” The second type includes those composite activities
that inherit from the flow control constructs but do not change the flow control logic implemented in the
flow control constructs from which they inherit. The main purpose behind implementing this second type
of composite activity is to assemble a custom activity from other composite or leaf activities. This enables
you to reuse the functionality implemented in other composite or leaf activities when you re building
your own custom activity.
Both types of composite activity directly or indirectly inherit from a base activity named
CompositeActivity, which in turn inherits from the Activity base class and exposes the members shown
in Listing 1 - 6 .
Listing 1 - 6: The CompositeActivity activity
public class CompositeActivity : Activity
{
// Methods
protected internal override void Initialize(
IServiceProvider provider);
protected internal override void Uninitialize(
IServiceProvider provider);
// Properties
public ActivityCollection Activities { get; }
protected internal bool CanModifyActivities { get; set; }
public ReadOnlyCollection < Activity > EnabledActivities { get; }
}
Note that the CompositeActivity activity does not override the Execute method. It is the responsibility of
the flow control constructs that inherit from the CompositeActivity activity to override this method to
include the logic that determines in which order the child activities of the composite activity should be
executed. You ll see examples of this later in this chapter.
CompositeActivity does override the Initialize method where it invokes the Initialize method of all its
containing child activities. CompositeActivity also overrides the Uninitialize method where it invokes
the Uninitialize methods of all its containing child activities.
Note that the CompositeActivity activity exposes a collection property named Activities, which is of the
ActivityCollection type. This is where the CompositeActivity activity maintains its child activities. The
CompositeActivity activity also exposes a read - only collection property named EnabledActivities, which
is of the ReadOnlyCollection < Activity > type. This collection contains references to all enabled activities
of the composite activity. An enabled activity is an activity whose Enabled property is set to true.
Disabling an activity or logical program statement is like commenting out a C# program statement.
A disabled activity does not participate in the execution of the composite activity. It is like dead code.
c01.indd 16c01.indd 16 8/25/08 4:02:56 PM8/25/08 4:02:56 PM