Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/319.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何将方法的返回值设置为CodeActivityContext_C#_Workflow_Workflow Foundation 4_Workflow Activity - Fatal编程技术网

C# 如何将方法的返回值设置为CodeActivityContext

C# 如何将方法的返回值设置为CodeActivityContext,c#,workflow,workflow-foundation-4,workflow-activity,C#,Workflow,Workflow Foundation 4,Workflow Activity,我正在编写一个活动,我几乎没有In-Arguments和OutArguments public OutArgument<List<xmlsStruct>> OutList { get; set; } protected override void Execute(CodeActivityContext context) { OutList = context.GetValue(this.getXMLData); } 我在上下文中遇到错误,说“有一些无效参数”,如何做请

我正在编写一个活动,我几乎没有In-Arguments和OutArguments

public OutArgument<List<xmlsStruct>> OutList { get; set; }
protected override void Execute(CodeActivityContext context)
{
OutList = context.GetValue(this.getXMLData);
}
我在上下文中遇到错误,说“有一些无效参数”,如何做请帮助
谢谢。

您的代码看起来有点不正确

由于getXMLData是一种方法,因此无法从执行上下文访问它。您可以通过调用方法的传统方式访问它

因此,您的活动代码类似于

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);
}
public OutArgument超过{get;set;}
//假设您将在此方法中编写一些代码来解析字符串并创建一个返回变量
公共列表getXMLData(字符串XMLResponse){return dataList}
受保护的覆盖无效执行(CodeActivityContext上下文)
{
//您需要从某处获取xml字符串变量。可能是InArgument?如果是,请使用context.GetValue(InargumemntName)
var dataList=this.getXMLData(“您的xml响应数据”);
SetValue(OutList、dataList);
}

希望这对您有所帮助。

在哪一步您会遇到异常。尝试使用setvalue设置参数中的值。
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);
}