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 ArgumentException
if the conditionally required fields aren't provided.
Another option is to have 2 activities, eg. File_Upload_WithCheckIn
and File_Upload_WithoutCheckIn
and only have the required arguments on the first one.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.