关于工作流书签的问题

时间:2011-08-18 11:46:00

标签: c# workflow workflow-foundation workflow-foundation-4 workflow-activity

我想知道如何在工作流书签中传递多个输入参数。我有这个代码

   public sealed class CodeActivity1 : NativeActivity<String>
{
    [RequiredArgument]
    public InArgument<string> BookmarkName { get; set; }

    protected override void Execute(NativeActivityContext context)
    {

        context.CreateBookmark(BookmarkName.Get(context),
            new BookmarkCallback(OnResumeBookmark));
    }

    // NativeActivity derived activities that do asynchronous operations by calling 
    // one of the CreateBookmark overloads defined on System.Activities.NativeActivityContext 

    protected override bool CanInduceIdle
    {
        get { return true; }
    }

    public void OnResumeBookmark(NativeActivityContext context, Bookmark bookmark, object obj)
    {
        Result.Set(context, (string)obj);
    }
}

当我恢复它时,如app.ResumeBookmark(“Test”,“inputTest”);.但是,如果我有例如2输出参数,如

,该怎么办?
        public InArgument<string> BookmarkName { get; set; }
        public OutArgument<string> Test1 {get; set;}
        public OutArgument<string> Test2 {get; set;}

如何使用app.ResumeBookmark()调用此书签?并从外面设置2个OutArguments with stirngs?就像app.ResumeBookmark(“Test”,“Inputtest1”,“Inputtest2”)? 感谢你的时间

2 个答案:

答案 0 :(得分:3)

您可以将所需的任何对象传递给ResumeBookmark()调用。因此,只需创建一个具有三个属性的类,并使用该类的实例。

答案 1 :(得分:0)

您可以尝试以下操作:

    public void OnResumeBookmark(NativeActivityContext context, Bookmark bookmark, object obj)    {        
        Test t = obj as Text;
        context.SetValue(this.Test1, t.S1);    
        context.SetValue(this.Test2, t.S2);    
    }