I am trying to create a custom activity for WF4 that host a child activity and pass some arguments to its child activity. I attach below a simplified version of my activities (Parent and Child)
public class Child : CodeActivity
{
public InArgument<Dictionary<string, object>> Data;
protected override void Execute(CodeActivityContext context)
{
Dictionary<string, object> data = Data.Get(context);
//Some operations on the input data
}
}
public class Parent : NativeActivity
{
public InArgument<int> Value1 { get; set; }
public InArgument<string> Value2 { get; set; }
public Child Body { get; set; }
protected override void Execute(NativeActivityContext context)
{
int value1 = Value1.Get(context);
string value2 = Value2.Get(context);
Dictionary<string, object> data = new Dictionary<string, object>();
data.Add("value1", value1);
data.Add("value2", value2);
context.SetValue(Body.Data, data);
context.ScheduleActivity(this.Body);
}
protected override void CacheMetadata(NativeActivityMetadata metadata)
{
Body = new Child();
base.CacheMetadata(metadata);
}
}
The Data argument from the Child activity is null when the workflow execution reaches the Execute method for the activity.
Can someone please, give me some direction how could the arguments be passed between this two activities?