none
Passing parameter from Parent Activity to Child Activity

    Pergunta

  • 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

    quinta-feira, 8 de março de 2012 21:23

Todas as Respostas