How do I execute a code activity from within a code activity?
public sealed class ApprovalRequired : CodeActivity
{
EmailActivity ea = new EmailActivity() // this is a code activity
ea.Sender = ...
ea.Rec = ...
ea.Subject = "Approved"
// ea.Execute() -- there is no way to call the execute method..
}
The easiest approach would be to prepare a XAML-based activity that has a sequence activity with your ApprovalRequired activity somewhere in it. Something like this:
Edit: To actually have an 'inner' activity be executed from another activity, your ApprovalRequired class should inherit from the
NativeActivity
class first, and override the CacheMetadata method to let the workflow application know to expect a child activity will be executed. The ApprovalRequired activity would look like this:Keep in mind that you'll need to manually register any activity arguments or activity variables in the ApprovalRequired's
CacheMetadata
method as well.