none
How to collect source location mapping of the children of an ActivityAction? RRS feed

  • Question

  • Hi,

    I created an activity that consists of two ActivityAction. Part1 will be executed first, followed by Part2

     

    public class MyActivity:NativeActivity
      {
        [Browsable(false)]
        public ActivityAction Part1 { get; set; }
        [Browsable(false)]
        public ActivityAction Part2 { get; set; } 
        [Browsable(false)]
        public Collection<Variable> Variables { get; set; }
    
        public MainWorkflow()
        {
          Variables=new Collection<Variable>();
        }
    
        protected override void CacheMetadata(NativeActivityMetadata metadata)
        {
          metadata.AddDelegate(Part1);
          metadata.AddDelegate(Part2);
          //metadata.
          base.CacheMetadata(metadata);
        }
    
        protected override void Execute(NativeActivityContext context)
        {
    
          context.ScheduleAction(Part1, ExecutePart2);
        }
    
        protected void ExecutePart2(NativeActivityContext context, ActivityInstance completedInstance)
        {
          context.ScheduleAction(Part2);
        }
    
      }
    

    Other than that, I also created a Tracking for the WorkflowApplication that executes this, following what is done in WF\Application\WorkflowSimulator of Microsoft's samples. However the method SourceLocationProvider.CollectMapping() in UpdateSourceLocationMappingInDebuggerService seems to only recognise MyActivity, Part1 and Part2 and ignores the children of Part1 and Part2 (I make Part1 and Part2 Sequences). Any idea how to make that method recognise the children of Part1 and Part2 as well?

    Thursday, January 27, 2011 3:20 AM

All replies

  • Any idea guys? Or is my question not clear enough?
    Friday, January 28, 2011 2:32 AM
  • I don't know of anything extra you are supposed to do besides metadata.AddDelegate(), I'm thinking it could possibly either a bug, or an issue related to generating source mapping from specific XAML, or the fact that you called base.CacheMetadata() at the end of the function instead of the start.

          metadata.AddDelegate(Part1);
          metadata.AddDelegate(Part2);
          //metadata.
          base.CacheMetadata(metadata);

    (it is possible that base.CacheMetadata will remove the things you added).

    Tim

    Sunday, January 30, 2011 4:40 AM
    Moderator
  • Unfortunately, I am not able to find the code for WorkflowSimulator, so I can't take a look at that.

    Regarding calling base.CacheMetadata - since your delegates are public, I don't think this will affect anything. base.CacheMetadata will use reflection to find the public delegate properties and replace the collection you started with your AddDelegate calls with a new one that has the same data in it. As long as you cover all your public properties in your override of CacheMetadata, you don't need to call base.CacheMetadata. But I don't believe doing so will hurt, either.

    Jim

    Wednesday, February 2, 2011 12:05 AM
    Moderator
  • @Jim: You can find it here, then browse to WF\Application\WorkflowSimulator. It is also featured here

     

    By the way, what is the difference between AddDelegate and AddChild? I know they take different parameters, but what are the difference between an Activity and an ActivityAction? other than the fact that an ActivityAction can take input parameter

    Saturday, February 5, 2011 8:24 AM
  • Using an ActivityAction defers the decision of what activity to run until runtime, just like a delegate in C# defers the decision of which method to call. It declares a "hole" that must be filled in at runtime before the workflow executes. If you use a child Activity at design time, you are tying the execution to that activity. But with ActivityAction, you are only committing yourself to a specific "signature" at design time.

    ForEach is an example of usage of an ActivityAction. You can use ForEach for any activity you want to execute, as long as it has the right signature.

    Jim

    Monday, February 7, 2011 7:43 PM
    Moderator
  • I don't know of anything extra you are supposed to do besides metadata.AddDelegate(), I'm thinking it could possibly either a bug, or an issue related to generating source mapping from specific XAML, or the fact that you called base.CacheMetadata() at the end of the function instead of the start.

          metadata.AddDelegate(Part1);
          metadata.AddDelegate(Part2);
          //metadata.
          base .CacheMetadata(metadata);

    (it is possible that base.CacheMetadata will remove the things you added).

    Tim

    Hi,

    removing cacheMetadata or moving it to the start doesn't work because then the activity will be invalid (a red error sign is displayed on the designer). This is the error message

    Wednesday, February 9, 2011 2:51 AM
  • Aha!

    The good news is that Error message is actually a sign you are doing something right. Seems like the error message really was going away because CacheMetadata was wiping out your delegate metadata, so moving CacheMetadata to the top should be the correct solution.

    The less good news is that you have an incomprehensible error message to find a solution to again...

    In this case I think if it is something about how you initialize or modify the values of your delegates and/or their handlers, Part1 and Part2. Do you have some more details to add on how you are doing that?

    Tim

    Wednesday, February 9, 2011 6:57 PM
    Moderator