// Workflow variable by Linq public void VariableByLinq() { // Linq treats local variable with special syntax. // See comment in LeafHelper.GetMemberAccessVariableExpression for more info. // The purpose test is to use real compiler generated lambda expression. Variable <string> var = new Variable <string>() { Name = "var", Default = "Linq var test" }; Expression <Func <ActivityContext, string> > expression = (env) => var.Get(env); CoreWf.Statements.Sequence expectedSequence = new CoreWf.Statements.Sequence() { Variables = { var }, Activities = { new WriteLine() { Text = var } } }; CoreWf.Statements.Sequence actualSequence = new CoreWf.Statements.Sequence() { Variables = { var }, Activities = { new WriteLine() { Text = ExpressionServices.Convert(expression) } } }; ExpressionTestRuntime.ValidateActivity(expectedSequence, actualSequence); }
public static Activity ConvertReferenceAndValidate <TResult>(Expression <Func <ActivityContext, TResult> > expr, Activity expectedActivity, Exception expectedException) { bool expectSuccess = expectedException == null ? true : false; Activity act = ExpressionTestRuntime.ConvertReference(expr, expectedException); if (expectSuccess) { ExpressionTestRuntime.ValidateActivity(act, expectedActivity); } act = ExpressionTestRuntime.TryConvertReference(expr, expectSuccess); if (expectSuccess) { ExpressionTestRuntime.ValidateActivity(act, expectedActivity); } return(act); }