how to set return value from a method to CodeActivityContext

726 views Asked by At

im coding a Activity and i have few In Arguments and OutArguments,

public OutArgument<List<xmlsStruct>> OutList { get; set; }

and i have a method called

 public List<xmlsStruct> getXMLData(string XMLResponse){
 return dataList }

i want to get that data list and assign to my OutArguments,

protected override void Execute(CodeActivityContext context)
{
OutList = context.GetValue(this.getXMLData);
}

im getting error on context saying "has some invalid arguments", how to do this please help thank you.

1

There are 1 answers

0
DotNetHitMan On

You code looks a bit incorrect.

As getXMLData is a method you cannot access it from the execution context. You can access it in the traditional manner of calling a method.

So your code for the activity would be something like.

public OutArgument<List<xmlsStruct>> OutList { get; set; }
//assuming that you will write some code in this method to parse the string and create a return var
public List<xmlsStruct> getXMLData(string XMLResponse){ return dataList }
protected override void Execute(CodeActivityContext context)
{
   //you will need to get you xml string var from somewhere. Maybe an InArgument<string> ? if so use context.GetValue(InargumemntName)
   var  dataList = this.getXMLData("Your xml response data");
   context.SetValue(OutList, dataList);
}

Hope this helps you.