locked
Hosted Designer:How to use arguments of direction Out and Property of a Custom Activity RRS feed

  • Question

  • I created a simple cutom activity called "Add.xaml" which  has Assign activity.

    The Add activity has following arguments of type Int32:
    Argument Direction : In
    Number1
    Number2

    Argument Direction : Out
    ResultOut

    Argument Direction : Property
    ResultProperty

    The Assign Activity has the following code
    To : ResultOut
    Value : Number1 + Number2

    I build the "Add" Activity and added to my hosted designer at ToolBoxControl.

    At hosted designer,how can I use "ResultOut" and "ResultProperty"?
    For example:If I add a sequence activity to hosted designer then add "Add" activity followed by "WriteLine" activity.
    I want to use the Out and Property argument of "Add" activity in "WriteLine" activity?
    Is it possible?

    Monday, November 16, 2009 11:47 AM

Answers

  • The only way you can use ResultOut property (OutArgument) is by giving it a variable to store the result in. ResultProperty should also not be used for passing 'results' of computations. In particular, you cannot reference either of them directly in the WriteLine activity. You need a variable to hold the data between the times the activities are executing.

    If you haven't seen it yet, you might like to check out Kenny and Matt's PDC08 talks, which includes introducing the workflow data model

    http://channel9.msdn.com/pdc2008/TL17/ (larger focus on data-model and run-time)
    http://channel9.msdn.com/pdc2008/TL21/ (larger focus on custom activities and how to use them)

    Tim
    Monday, November 16, 2009 3:50 PM
  • The main nice thing about Property compared to Arguments is that you can evaluate them at Design time, so you could bind to the value in your design time experience at interesting ways. For example the 'Then' and 'Else' branches of an If activity are properties, and this is how we can show the contained activities in the workflow designer. If the activities to execute were being computed dynamically at runtime we couldn't really do that.

    Tim
    • Marked as answer by sans_india85 Wednesday, November 18, 2009 3:57 AM
    Tuesday, November 17, 2009 11:18 PM

All replies

  • The only way you can use ResultOut property (OutArgument) is by giving it a variable to store the result in. ResultProperty should also not be used for passing 'results' of computations. In particular, you cannot reference either of them directly in the WriteLine activity. You need a variable to hold the data between the times the activities are executing.

    If you haven't seen it yet, you might like to check out Kenny and Matt's PDC08 talks, which includes introducing the workflow data model

    http://channel9.msdn.com/pdc2008/TL17/ (larger focus on data-model and run-time)
    http://channel9.msdn.com/pdc2008/TL21/ (larger focus on custom activities and how to use them)

    Tim
    Monday, November 16, 2009 3:50 PM
  • tilovell:The only way you can use ResultOut property (OutArgument) is by giving it a variable to store the result in.

    Thanks for the precise information and the links.

    Can you please  provide more information about Argument Direction: Property and how to use them in the hosted designer?

    In hosted designer scenarios:
    In Arguments are used to give input to the activities.
    Out Arguments are used to get computed output as mentioned in the above example and give a variable to get the result
    In the same way how to use Property Arguments using the above example or any other example? XAML Code:<x:Property Name="ResultProperty" Type="x:Int32" />

    In continuation with the above example:
    The Assign Activity has the following code
    To : ResultProperty
    Value : Number1 + Number2

    or

    To : ResultOut
    Value : Number1 + ResultProperty

    I get an error saying that ResultProperty is not declared.

    Tuesday, November 17, 2009 2:26 PM
  • The main nice thing about Property compared to Arguments is that you can evaluate them at Design time, so you could bind to the value in your design time experience at interesting ways. For example the 'Then' and 'Else' branches of an If activity are properties, and this is how we can show the contained activities in the workflow designer. If the activities to execute were being computed dynamically at runtime we couldn't really do that.

    Tim
    • Marked as answer by sans_india85 Wednesday, November 18, 2009 3:57 AM
    Tuesday, November 17, 2009 11:18 PM
  • Final Conclusion
    In Hosted Designer Scenarios:
    For argument direction "Property",
    At runtime: If the activities to execute were being computed dynamically at runtime we couldn't really do that.
    Wednesday, November 18, 2009 3:57 AM