[Designer(typeof(CompositeDesigner))]
public class MyCompsiteActivity : NativeActivity
{
public Variable<int> Index = new Variable<int>();
public Activity DoWhileActivity { get; set; }
public MyCompsiteActivity()
{
DoWhileActivity = CreateDoWhile();
}
protected override void CacheMetadata(NativeActivityMetadata metadata)
{
metadata.AddChild(DoWhileActivity);
metadata.AddImplementationVariable(this.Index);
base.CacheMetadata(metadata);
}
protected override void Execute(NativeActivityContext context)
{
context.ScheduleActivity(this.DoWhileActivity, onActivityCompleted);
//ScheduleActivities(context);
}
void ScheduleActivities(NativeActivityContext context)
{
}
void onActivityCompleted(NativeActivityContext context, ActivityInstance instance)
{
ScheduleActivities(context);
}
private Activity CreateDoWhile()
{
Variable<bool> VResult = new Variable<bool>("VResult", false);
return new DoWhile()
{
DisplayName = "DoWhile",
Variables = { VResult },
Condition = ExpressionServices.Convert<bool>(env => VResult.Get(env)),
Body = new Sequence()
{
DisplayName = "DoWhile Body",
Activities =
{
new If()
{
DisplayName = "If Then Else",
//Code to be added here in Level 2
Condition = ExpressionServices.Convert<bool>(env => VResult.Get(env)),
Then = new IFThenActivity() { DisplayName="Set Resut True", InOutResult=VResult},
Else = new IFElseActivity(){ DisplayName="Double Click End Key"}
}
}
}
};
}
}
public sealed class IFElseActivity : CodeActivity
{
protected override void Execute(CodeActivityContext context)
{
Console.WriteLine("Double Press End Keys!");
}
}
public sealed class IFThenActivity : CodeActivity
{
public InOutArgument<bool> InOutResult { get; set; }
protected override void Execute(CodeActivityContext context)
{
Console.WriteLine("Set InOutResult True!");
bool s1 = context.GetValue(this.InOutResult);
Console.WriteLine("Preset is :"+s1);
context.SetValue(this.InOutResult, true);
Console.WriteLine("Postset is :" + s1);
}
}