简体   繁体   English

在工作流C#中设置参数的值

[英]Setting the argument's value in workflow c#

I am using Windows Workflow Foundation .NET 4.5.2. 我正在使用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. 我从CodeActivity内部在设计器中设置bool类型的参数(也可能是变量)时遇到问题。

In the designer, I set the argument newProject of type bool with direction In . 在设计器中,我设置了方向为In bool类型的newProject参数。 (should it have another direction? ie InOut ). (它应该有另一个方向吗?即InOut )。

In code I want to set the argument from designer to value true . 在代码中,我想将设计器的参数设置为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. 如果是true ,我可以进入下一个状态。 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? 如何做呢?

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM