Passing parameter from Parent Activity to Child Activity
-
Donnerstag, 8. März 2012 21:23
I have few custom native activities.
Any activity can appear into any other and I have to pass parameter from parent activity to child but I am not able to.
Please see sample code.
public sealed class Activity1 : NativeActivity { public InOutArgument<ClassAbc> ClassAbc { get; set; } public Activity Body { get; set; } protected override void CacheMetadata(NativeActivityMetadata metadata) { RuntimeArgument argument1 = new RuntimeArgument("ClassAbc", typeof(ClassAbc), ArgumentDirection.InOut); metadata.Bind(ClassAbc, argument1); metadata.AddArgument(argument1); DelegateInArgument<ClassAbc> delegateInArgument = new DelegateInArgument<ClassAbc>() { Name = "ClassAbc" }; activityAction = new ActivityAction<ClassAbc>() { Argument = delegateInArgument, DisplayName = Guid.NewGuid().ToString(), Handler = Body }; metadata.AddDelegate(activityAction); } protected override void Execute(NativeActivityContext context) { ClassAbc classAbc = new ClassAbc(); classAbc.RecordNumber = 100; context.ScheduleAction<RecordNumberResponse>(activityAction, classAbc, Completed); } private void Completed(NativeActivityContext context, ActivityInstance instance) { } } public sealed class Activity2 : NativeActivity { public InOutArgument<ClassAbc> ClassAbc { get; set; } public Activity Body { get; set; } protected override void CacheMetadata(NativeActivityMetadata metadata) { RuntimeArgument argument1 = new RuntimeArgument("ClassAbc", typeof(ClassAbc), ArgumentDirection.InOut); metadata.Bind(ClassAbc, argument1); metadata.AddArgument(argument1); DelegateInArgument<ClassAbc> delegateInArgument = new DelegateInArgument<ClassAbc>() { Name = "ClassAbc" }; activityAction = new ActivityAction<ClassAbc>() { Argument = delegateInArgument, DisplayName = Guid.NewGuid().ToString(), Handler = Body }; metadata.AddDelegate(activityAction); } protected override void Execute(NativeActivityContext context) { ClassAbc classAbc = new ClassAbc(); classAbc.RecordNumber = 100; context.ScheduleAction<RecordNumberResponse>(activityAction, classAbc, Completed); } private void Completed(NativeActivityContext context, ActivityInstance instance) { } }
I should be able to pass Activity1 in Activity2 using Property Body and vice-versa. And they should be able to parent should be able to pass ClassAbc to child activity.
But while executing above code value is coming as Null. I am sure I am doing soemthing wrong but not sure what and how to fix that.
Please advice.
Software Engineer
Alle Antworten
-
Sonntag, 11. März 2012 12:04You cannot pass a value directly from one activity to another, for further help you can read Jacob's blog http://blogs.msdn.com/b/rjacobs/archive/2011/05/25/passing-values-between-workflow-activities.aspx
- Als Antwort vorgeschlagen Arvand Fazeli Dienstag, 13. März 2012 16:59
- Nicht als Antwort vorgeschlagen Ram Kinkar Pandey Dienstag, 13. März 2012 17:06
-
Dienstag, 13. März 2012 17:05
Hello Arvand,
Thanks for your response.
I went through the link you posted I have already tried that that works like any other In or InOut parameter works but with increasing complexity in my applicaiton it's not useful.
If I will go with above method then I will have access to that parameter even if my activity is not a child activity. This is not acceptable in my case.
regards,
Software Engineer

