1

我正在使用 Windows Workflow Foundation .NET 4.5.2。我有一个关于bool从 CodeActivity 内部在设计器中设置类型参数(也可能是变量)的问题。

在设计器中,我将newProjecttype的参数设置为booldirection In。(它应该有另一个方向吗?即InOut)。

在代码中,我想将参数从设计器设置为 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);
         }
     }
 }

设计器中的论点在使我能够进入下一个状态的转换中得到验证。如果是true,我可以进入下一个状态。问题是设计器中的参数没有收到上面代码中设置的新值。怎么做到呢?

4

1 回答 1

0

如果要将值传回设计器,则需要将其设为 Out 参数或 InOut 参数。

于 2016-12-15T17:27:51.237 回答