public static IEnumerable <IOption> Execute <T>(this OperationWorkflow workflow, T host, OperationArgParser parser = null) { var requested = Describe <T>(workflow); foreach (var i in requested.Where(i => i.IsNone())) { yield return(i); } var available = requested.Where(i => i.Exists).Select(i => i.Require()).ToList(); foreach (var invocation in available) { yield return(Execute(invocation, host, parser)); } }
public static IEnumerable <Option <ClrMethodCallDescription> > Describe <T>(this OperationWorkflow workflow) { var contract = DescribeContract <T>(); var activeOps = workflow.Steps.Where(i => i.IsActive).ToList(); var descriptions = from active in some(activeOps) let xyz = activeOps.Select( execSpec => from op in execSpec.DescribeOperation <T>() from inv in contract.DescribeInvocation(execSpec) select inv ) select xyz; return(descriptions.ValueOrDefault(stream <Option <ClrMethodCallDescription> >())); }