locked
How to get this.Parent in execute method of activity. RRS feed

  • Question

  • Hi,

    Inside execute "protected override void Execute" of the NativeActivity i want to get its parent. 

     

    protected override void Execute
        (
        NativeActivityContext context
        )
          {
    	this.Parent
    Actually my problem is that i want to check if this activity is in sequence or parallel during execution. Please help me. 

     


    ilogik
    Saturday, August 28, 2010 3:37 PM

Answers

  • I overcome my above issue using following trick.

    In my activity class i added follwoing varialbe

    public string ContainerActivity { get; set; }
    

    and designer class i assigned it value of parent container

    public FilterDesigner ()
          {
          InitializeComponent ();
          this.Loaded += new RoutedEventHandler (FilterDesigner_Loaded); 
          }
    
        void FilterDesigner_Loaded (object sender, RoutedEventArgs e)
          {
          (this.ModelItem.GetCurrentValue () as Filter).ContainerActivity = GetParentActivity (this.ModelItem).ItemType.ToString ();
          }

    and finally in execute method i was able to this.ContainerActivity

    protected override void Execute
      (
      NativeActivityContext context
      )
        {
    
    
    this.ContainerActivity
    

    Thanks for your help guys.


    ilogik
    Wednesday, September 1, 2010 7:55 AM

All replies

  • Just curious, why is knowing that useful? (And does it matter if it is in a sequence that is inside a parallel, etc? Or in another activity that schedules activities in parallel such as Pick?)

    Tim

    Saturday, August 28, 2010 11:42 PM
  • Actually am doing some auto mapping of out of previous activity with input of the current. so this logic is different for sequence. in case of sequence i have to pick just out put of  activity that executed previously. but in case of parallel this is not the case? that's why i need to know is it sequence or parallel.
    ilogik
    Sunday, August 29, 2010 4:15 AM
  • I overcome my above issue using following trick.

    In my activity class i added follwoing varialbe

    public string ContainerActivity { get; set; }
    

    and designer class i assigned it value of parent container

    public FilterDesigner ()
          {
          InitializeComponent ();
          this.Loaded += new RoutedEventHandler (FilterDesigner_Loaded); 
          }
    
        void FilterDesigner_Loaded (object sender, RoutedEventArgs e)
          {
          (this.ModelItem.GetCurrentValue () as Filter).ContainerActivity = GetParentActivity (this.ModelItem).ItemType.ToString ();
          }

    and finally in execute method i was able to this.ContainerActivity

    protected override void Execute
      (
      NativeActivityContext context
      )
        {
    
    
    this.ContainerActivity
    

    Thanks for your help guys.


    ilogik
    Wednesday, September 1, 2010 7:55 AM