I have build a custom activity for Workflow Foundation which works exactly as exprected and I'mno implementing some validation on the arguments.
I have 4 arguments, the first 2 File_Location and CheckIn are required, and the validation [RequiredArgument] works fine. Is there a way of making the last 2 arguments CheckInComment and chekintype required if CheckIn is true.
public sealed class File_Upload : CodeActivity
{
[Category("Input")]
[DisplayName("Location of file to upload")]
[RequiredArgument]
public InArgument<string> File_Location { get; set; }
[Category("Input")]
[DisplayName("Check in file?")]
[RequiredArgument]
public InArgument<bool> CheckIn { get; set; }
[Category("Input")]
[DisplayName("Check in comment")]
//Required if CheckIn == True
public InArgument<string> CheckInComment { get; set; }
[Category("Input")]
[DisplayName("Check in type")]
//Required if CheckIn == True
public InArgument<CheckinType> chekintype { get; set; }
protected override void Execute(CodeActivityContext context)
{
//MY CODE
}
}
I don't think there's a way to do this exactly.
You could check at runtime though and throw an
ArgumentExceptionif the conditionally required fields aren't provided.Another option is to have 2 activities, eg.
File_Upload_WithCheckInandFile_Upload_WithoutCheckInand only have the required arguments on the first one.