using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Activities;
namespace WorkflowConsoleApplication3
{
public sealed class InputDataActivity : CodeActivity
{
// 定义一个字符串类型的活动输入参数
public OutArgument<int> Money { get; set; }
// 如果活动返回值,则从 CodeActivity<TResult>
// 派生并从 Execute 方法返回该值。
protected override void Execute(CodeActivityContext context)
{
string money = Console.ReadLine();
int mnoy = 0;
try
{
mnoy = int.Parse(money);
}
catch (Exception)
{
Console.WriteLine("你输入的不是整数");
} context.SetValue(Money, mnoy);
// 获取 Text 输入参数的运行时值
// string text = context.GetValue(this.Text);
}
}
------------------------------------------------------------------------------
-------------------------------------------------------------------------------------------
using System; using System.Linq; using System.Activities; using System.Activities.Statements;
namespace WorkflowConsoleApplication3
{
class Program
{
static void Main(string[] args)
{
Activity workflow1 = new Workflow1();
WorkflowInvoker.Invoke(workflow1);
Console.ReadKey();
}
}
}
}