Question

I have a bit of a twist that is a little more trouble than I thought it would be. Normally I would have an InArgument and use it as below:

public InArgument<Int32> XYZ_ID { get; set; }
public InArgument<Int32> XYZ_COUNT { get; set; }

protected override IAsyncResult BeginExecute(...)
{
....snip....
_ABC_ID = XYZ_ID.Get(context),
_ABC_Count = XYZ_COUNT.Get(context)

This works great and I thought a custom object we be close to the same process but I can't seem to figure it out. ActvUsrPrgmResults is just a class of properties such as AccountName, FirstName etc. So I passed it in like any other type.

public InArgument<bool> IsHappy { get; set; }
public InArgument<bool> IsClapping { get; set; }
public InArgument<ActvUsrPrgmResults> itm_ActvUsrPrgm { get; set; }

Accessing it though is a bit more difficult....for me.

protected override void Execute(CodeActivityContext context)
{
    NewPerson x = new NewPerson
    {
        AccountName = this.itm_ActvUsrPrgm.Get(?????
        //this doesn't work either
        AccountName = itm_ActvUsrPrgm.?????

In other words I can't see how to access the properties of the itm_ActvUsrPrgm InArgument.

Thank You for any help or direction JB

Additional Info

I have this CodeActivity in a ForEach (List). So each item in the generic collection is a single instance of ActvUsrPrgmResults. So I hand this off to my CodeActivity thinking I will have a handle to manipulate that item's data????

Interesting

Now based upon Will's comments I got to thinking about this slight of hand. It works but shouldn't there be a more elegant approach?

public InArgument<bool> IsHappy { get; set; }
public InArgument<bool> IsClapping { get; set; }
public InArgument<ActvUsrPrgmResults> itm_ActvUsrPrgm { get; set; }

protected override void Execute(CodeActivityContext context)
{
    ActvUsrPrgmResults y = itm_ActvUsrPrgm.Get(context);
    NewPerson x = new NewPerson
    {
        AccountName = y.AccountName....
Was it helpful?

Solution

The problem is me, myself, and I. I wasn't getting a handle on the object being passed in. For some under the covers reason an "InArgument" is not immediately accessible until you get a firm grasp on the exact object from the given context. I don't know for sure but I suspect this is due to multiple workflows running so you can't just grab any ole object ytou must get the object from the proper context. Anyway here are my comments of what I learned inline.

public InArgument<bool> IsHappy { get; set; } //bool variable being passed in
public InArgument<bool> IsClapping { get; set; } //bool variable being passed in
public InArgument<ActvUsrPrgmResults> itm_ActvUsrPrgm { get; set; } //custom object being passed in

protected override void Execute(CodeActivityContext context)
{
    bool Happy = context.GetValue(this.IsHappy);
    bool Clap = context.GetValue_this.IsClapping);
    ActvUsrPrgmResults y = context.GetValue(this.itm_ActvUsrPrgm);
    //NOW!!! we have a handle to the proper objects for this context

    //This also works. I just flip flopped the InArgument property and the context.
    ActvUsrPrgmResults y = itm_ActvUsrPrgm.Get(context);

    NewPerson x = new NewPerson
    { 
        AccountName = y.AccountName....
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top