如何将 windows 工作流的参数内参数传递给自定义代码 activity 属性?

How to pass the In-argument parameters of windows workflow to a custom code activity properties?

        //adding parameters and invoking workflow but the properties inside the codeactivity is all
    static void Main(string[] args)
    {
      Activity workflow1 = new Workflow1();//activity
      IDictionary<string, object> parameters = new Dictionary<string, object>();
      parameters.Add("toFolder", @"C:\BackupByWorkFlow");//param1
      parameters.Add("fromFolder", @"C:\");//param2
       WorkflowInvoker.Invoke(workflow1, parameters);//invoke
    }

// workflow1 contains sequence of activities

// sequence->WhileBackup activity -> and  other custom activities

      //Custom code activity in workflow is as below
    public sealed class WhileBackup : CodeActivity
     {
       // Defining properties
           public InArgument<string> Text { get; set; }
            public InArgument<string> toFolder { get; set; }//property is null
            public InArgument<string> fromFolder { get; set; }//property is null
            public int totalFiles { get; set; }
            public int currentFile;
            public  FileInfo[] files;

        // If your activity returns a value, derive from CodeActivity<TResult>
        // and return the value from the Execute method.
          protected override void Execute(CodeActivityContext context)
                  {
                       // Obtain the runtime value of the Text input argument
                       string text = context.GetValue(this.Text);
                 }
    }

workflow的in-argument值不为null但在代码中相同activity在同一个workflow中是null.hence我想知道如何传递workflow的in参数的值代码 activity 属性.

您传递给 Invoke 的参数作为参数传递给工作流,但它们不会自动向下传递到工作流中的活动。

在工作流定义中,您必须定义要传递给工作流的参数,并且必须将 toFolder 和 fromFolder 参数显式映射到 activity 的 toFolder 和 fromFolder 属性。

请注意,参数和属性的名称不必匹配,使它们匹配并不意味着任何事情。