开发者

How can I, in Workflow Foundation 4.0, read the value of an InArgument outside of the Execute method of the Activity in which it has been declared?

开发者 https://www.devze.com 2023-04-12 23:58 出处:网络
How do I access or read t开发者_开发知识库he value of an InArgument outside of the Execute method of the Activity in which it has been declared?

How do I access or read t开发者_开发知识库he value of an InArgument outside of the Execute method of the Activity in which it has been declared?

I tried invoking the get method by passing the NativeActivityContext, but that just resulted in getting a "declare the argument on the activity" message.

Type t = typeof(System.Activities.InArgument<>).MakeGenericType(typeof(Test.Entities.Agent));
object obj = Activator.CreateInstance(t);

MethodInfo dd = t.GetMethod("Get");
object magic = dd.Invoke(obj, new object[] { (System.Activities.ActivityContext)context });


Not sure where your context comes from but it looks like it wasn't provided by the workflow runtime. The workflow runtime managers all arguments and variables for you and let you get at data through the NativeActivityContext. These aren't types you can just use somewhere else they depend on the internal structures provided by the runtime. If you are trying to unit test an activity you should use the WorkflowInvoker to execute your activity. Use activity extensions to separate the activity, the intent, with the actual implementation, the extension.

0

精彩评论

暂无评论...
验证码 换一张
取 消