从 CodeActivity() 访问 InArgument

发布于 2024-11-19 19:07:16 字数 717 浏览 1 评论 0原文

我很乐意得到你的帮助。我是工作流新手,我在工作流中定义了一些我想在不同活动中访问的 InArguments。在我的测试项目中,我有一个名为“Text”的 InArgument,它具有默认值。我试图通过这样做在我的活动中访问这个值。

 public InArgument<String> Text { get; set; }

    protected override void Execute(CodeActivityContext context)
    {
        Console.WriteLine(string.Format("{0}.{1} Start Date Time", MethodInfo.GetCurrentMethod().DeclaringType.Name, MethodInfo.GetCurrentMethod().Name, DateTime.Now.ToString()));
        Console.WriteLine(string.Format("Eric the text is: {0}", Text.Get(context)));
        Console.ReadLine();
    }

我创建了与工作流全局 InArgument 同名的本地 InArgument。当我执行 get 时,它返回的值为 null。我尝试访问上下文对象,但无法获取属性的值(尽管我看到了属性的名称)。如果这是微不足道的,我深表歉意,但我希望得到您的帮助。

谢谢你!

I would love your help. I am new to Workflow and I have define some InArguments in my workflow that I want to access in different activities. In my test project I have a InArgument named "Text" which has a default value. I am trying to access this value within my activity by doing this.

 public InArgument<String> Text { get; set; }

    protected override void Execute(CodeActivityContext context)
    {
        Console.WriteLine(string.Format("{0}.{1} Start Date Time", MethodInfo.GetCurrentMethod().DeclaringType.Name, MethodInfo.GetCurrentMethod().Name, DateTime.Now.ToString()));
        Console.WriteLine(string.Format("Eric the text is: {0}", Text.Get(context)));
        Console.ReadLine();
    }

I have created the local InArgument with the same name as the InArgument global to the workflow. When I do the get, the value that it is returning is null. I tried to access the context object but have been unable to get to the property's value (although I saw the property's name). I apologize if this is trivial, but I would love your help.

Thank you!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

记忆で 2024-11-26 19:07:16

活动中的代码看起来不错。当您将活动添加到工作流程时,您在 Text 属性中添加了什么表达式?因为这决定了您读取的值,所以 InArgument 没有与工作流中的某些内容无关的默认值。

The code in the activity looks fine. What for expression did you put in the Text property when you added the activity to your workflow? Because that determines the value you read, there is no default value for an InArgument that is not tied to something in the workflow.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文