从 CodeActivity() 访问 InArgument
我很乐意得到你的帮助。我是工作流新手,我在工作流中定义了一些我想在不同活动中访问的 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技术交流群](/public/img/jiaqun_03.jpg)
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
活动中的代码看起来不错。当您将活动添加到工作流程时,您在 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.