Reputation: 18679
How do I access or read the 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 });
Upvotes: 0
Views: 655
Reputation: 27632
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.
Upvotes: 1