locked
ActivityContext vs LocationEnvironment RRS feed

  • Question

  • I'm trying to better understand the difference between these two classes.  In particular, I'm interested in the real purpose for the LocationEnvironment. 

    I've seen where it primarily seems to be used in Get/Set methods for variables and arguments.  In one overload passing the LE directly and in another overload using a delegate (lambda) that expects a LE to be passed.  And I've seen the example code where this object is used when you build a new activity in code out of existing activities (one good example is in the GuessingGame custom activities).  And the ActivityContext (and it's derived classes) also has an Environment property which is a LE, so there is some relationship between the two. 

    So while I can see how it might be used, I'm not really clear as to why.  What "location" or "environment" is it tracking for you?  What does it do that ActivityContext doesn't?

    Thanks.

    Bruce Bukovics http://www.learnworkflow.com
    Wednesday, July 15, 2009 4:58 PM

Answers

  • Thanks for the question Bruce.  The runtime manages state (ex. variable values) associated with an activity instance in a LocationEnvironment.  ActivityContext is an activity's proxy into the runtime for doing things like manipulating state.  As you've observed, there is duplicate functionality across ActivityContext and LocationEnvironment.  We've made LocationEnvironment internal in Beta2.

    Cheers,
    Ed Pinto - MSFT
    Friday, July 17, 2009 5:35 PM

All replies

  • Thanks for the question Bruce.  The runtime manages state (ex. variable values) associated with an activity instance in a LocationEnvironment.  ActivityContext is an activity's proxy into the runtime for doing things like manipulating state.  As you've observed, there is duplicate functionality across ActivityContext and LocationEnvironment.  We've made LocationEnvironment internal in Beta2.

    Cheers,
    Ed Pinto - MSFT
    Friday, July 17, 2009 5:35 PM
  • Thanks for the explanation.

    Can I assume then that the Get/Set methods that previously required a LE will now take an ActivityContext?
    Bruce Bukovics http://www.learnworkflow.com
    Friday, July 17, 2009 6:40 PM
  • Yes you can.

    Cheers,
    Ed - MSFT
    Friday, July 17, 2009 9:17 PM