Setting the argument's value in workflow c#

574 views Asked by At

I am using Windows Workflow Foundation .NET 4.5.2. I have an issue regarding setting an argument of type bool (could be also a variable) in designer from inside CodeActivity.

In the designer, I set the argument newProject of type bool with direction In. (should it have another direction? i.e. InOut).

In code I want to set the argument from designer to value true.

 public class Inquire : CodeActivity
 {
    public InArgument<bool> newProject { get; set; }

    public InArgument<bool> rework { get; set; }

    protected override void Execute(CodeActivityContext context)
    {
         Console.WriteLine("For a new project type 'new', for rework type 'rw'.");
         string inquire = Console.ReadLine();

         if (inquire == "new")
         {
             context.SetValue(newProject, true);
         }
         else
         {
             rework.Set(context, true);
         }
     }
 }

The argument in the designer is verified in a transition that enables me to get to the next state. If it is true, I can get to the next state. The problem is that the argument in the designer does not receive the new value that is set in the code above. How can it be done?

1

There are 1 answers

1
helmsb On

If you want to pass the value back out the designer you need to make it either an Out argument or an InOut argument.