Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>If your 'predicate' is a well-known string and don't need to be an expression evaluated at runtime you surely can do something like this, throwing away the <em>InArgument</em> and avoid the constructor:</p> <pre><code>public class Eval&lt;T, TResult&gt; : Activity&lt;TResult&gt; { public string Expression { get; set; } [RequiredArgument] public InArgument&lt;T&gt; Value { get; set; } protected override Func&lt;Activity&gt; Implementation { get { if (string.IsNullOrEmpty(Expression)) { return base.Implementation; } return () =&gt; new Assign&lt;TResult&gt; { Value = new InArgument&lt;TResult&gt;(new VisualBasicValue&lt;TResult&gt;(Expression)), To = new ArgumentReference&lt;TResult&gt;("Result") }; } set { throw new NotSupportedException(); } } } </code></pre> <p>and call it this way:</p> <pre><code>var activity = new Eval&lt;int, int&gt;() { Expression = "Value + 2" }; var inputArgs = new Dictionary&lt;string, object&gt;() { { "Value", 5 } }; Console.WriteLine("RESULT: " + WorkflowInvoker.Invoke&lt;int&gt;(activity, inputArgs)); </code></pre> <hr/> <p><strong>EDIT</strong>: check that even with <code>Predicate.ExpressionText</code> not commented, it has no effect whatsoever:</p> <pre><code>public class NativeEval&lt;T, TResult&gt; : NativeActivity&lt;TResult&gt; { [RequiredArgument] public InArgument&lt;string&gt; ExpressionText { get; set; } [RequiredArgument] public InArgument&lt;T&gt; Value { get; set; } private Assign Assign { get; set; } private VisualBasicValue&lt;TResult&gt; Predicate { get; set; } private Variable&lt;TResult&gt; ResultVar { get; set; } protected override void CacheMetadata(NativeActivityMetadata metadata) { base.CacheMetadata(metadata); Predicate = new VisualBasicValue&lt;TResult&gt;("ExpressionText.Length"); ResultVar = new Variable&lt;TResult&gt;("ResultVar"); Assign = new Assign { To = new OutArgument&lt;TResult&gt;(ResultVar), Value = new InArgument&lt;TResult&gt;(Predicate) }; metadata.AddImplementationVariable(ResultVar); metadata.AddImplementationChild(Assign); } protected override void Execute(NativeActivityContext context) { // this line, commented or not, is the same! Predicate.ExpressionText = ExpressionText.Get(context); context.ScheduleActivity(Assign, new CompletionCallback(AssignComplete)); } private void AssignComplete(NativeActivityContext context, ActivityInstance completedInstance) { // the result will always be the ExpressionText.Length Result.Set(context, ResultVar.Get(context)); } } </code></pre> <p>When you get at <code>Execute()</code> method changing the child implementation has no effect. The execution mode is on and the children tree cannot be altered. </p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload