+1  A: 

ScheduleFunc always takes a ActivityFunc where your condition is defined as ActivityFunc. Not sure where the non generic ActivityFunc comes from. Also the CompletionCallback should be a CompletionCallback.

Update: The test code I used:

IActivityTemplateFactory factory = new Trigger();
var trigger = (Trigger)factory.Create(null);
trigger.Condition.Handler = new AlwaysTrue();
trigger.Child.Handler = new WriteLine()
{
    Text = "Its true."
};
WorkflowInvoker.Invoke(trigger);

class AlwaysTrue : CodeActivity<bool>
{
    protected override bool Execute(CodeActivityContext context)
    {
        return true;
    }
}

And the IActivityTemplateFactory.Create:

Activity IActivityTemplateFactory.Create(System.Windows.DependencyObject target)
{
    return new Trigger()
    {
        Child = new ActivityAction()
        {
            DisplayName = "Trigger Child Action"
        },

        Condition = new ActivityFunc<bool>()
        {
            DisplayName = "Trigger Conditionals"
        },
        DisplayName = "Trigger"
    };
}
Maurice
2.CompletionCallback should be a CompletionCallback. -CompletionCallback is a CompletionCallback, I'm instantiating it in the schedule method. Unless there is another way I should be doing it?
Terrance
1.ScheduleFunc always takes a ActivityFunc where your condition is defined as ActivityFunc. Not too sure what you mean. The ref is here http://msdn.microsoft.com/en-us/library/dd486077.aspx and My condition is defined as a ActivityFunc.
Terrance
Hmm. Seems I was loosing some formating. It should have read ActivityFunc < T >
Maurice
Duh, yeah I did the same thing. Should be fixed now. and code should make a lot more sense.
Terrance
Yes it does :-) Removing the line with Result = new DelegateOutArgument < bool > () from the IActivityTemplateFactory.Create() seems to fix the problem for me.
Maurice
I gave that a try and am still getting nothing but false passed to the method OnConditionComplete.
Terrance
This is my test workflow and it works just fine: IActivityTemplateFactory factory = new Trigger();var trigger = (Trigger)factory.Create(null);trigger.Condition.Handler = new AlwaysTrue();trigger.Child.Handler = new WriteLine(){ Text = "Its true."};WorkflowInvoker.Invoke(trigger);
Maurice
Your test works fine, But I am still getting false results from my ActivtyFunc<bool> Conditions that I am attempting to use in my production code. So it looks like they may be the culprit.
Terrance
Well thanks for helping me figure out one of the things its not.
Terrance
+1  A: 

Hello someone who I have never met before and just happens to share my IP.

You're doing something wrong. Elsewhere, that is.

Either the DLL with the activities you're using isn't fresh, or the workflow definition is out of date and doesn't hold what you believe it does. Or its something completely different.

I've stripped down your code and compressed it into a sample project. Like to see it here we go:

This is the simple condition:

public sealed class AnTrigger : NativeActivity<bool>
{
    public bool ResultToSet { get; set; }

    protected override void Execute(NativeActivityContext context)
    {
        Result.Set(context, ResultToSet);
    }
}

Simple, no? Here's the host that evaluates this condition and, if it returns true, runs a single child activity. Note, I'm constructing the activity in the Create method so I don't have to create an editor.

public sealed class AnTriggerHost : NativeActivity, IActivityTemplateFactory
{
    public ActivityFunc<bool> Condition { get; set; }
    public ActivityAction Child { get; set; }

    protected override void Execute(NativeActivityContext context)
    {
        context.ScheduleFunc(Condition, OnConditionComplete);
    }

    private void OnConditionComplete(
        NativeActivityContext context, 
        ActivityInstance completedInstance, 
        bool result)
    {
        if (result)
            context.ScheduleAction(Child);
    }

    Activity IActivityTemplateFactory.Create(System.Windows.DependencyObject target)
    {
        // so I don't have to create UI for these, here's a couple samples
        // seq is the first child and will run as the first AnTrigger is configured to return true
        // so the first trigger evals to true and the first child runs, which
        var seq = new Sequence
        {
            DisplayName = "Chief Runs After First Trigger Evals True"
        };
        // prints this message to the console and
        seq.Activities.Add(new WriteLine { Text = "See this?  It worked." });
        // runs this second trigger host, which 
        seq.Activities.Add(
            new AnTriggerHost
            {
                DisplayName = "This is the SECOND host",
                Condition = new ActivityFunc<bool>
                {
                    // will NOT be triggered, so you will never see
                    Handler = new AnTrigger
                    {
                        ResultToSet = false,
                        DisplayName = "I return false guize"
                    }
                },
                Child = new ActivityAction
                {
                    // this activity write to the console.
                    Handler = new WriteLine
                    {
                        Text = "you won't see me"
                    }
                }
            });

        return new AnTriggerHost
        {
            DisplayName = "This is the FIRST host",
            Condition = new ActivityFunc<bool>
            {
                Handler = new AnTrigger
                {
                    ResultToSet = true,
                    DisplayName = "I return true!"
                }
            },
            Child = new ActivityAction
            {
                Handler = seq
            }
        };
    }
}

Drop these two in a Workflow Console app and drop the AnTriggerHost on the workflow. Set ye a couple breakpoints and watch it fly. Here's the workflow xaml:

  <local:AnTriggerHost DisplayName="This is the FIRST host" >
    <local:AnTriggerHost.Child>
      <ActivityAction>
        <Sequence DisplayName="Chief Runs After First Trigger Evals True">
          <WriteLine Text="See this?  It worked." />
          <local:AnTriggerHost DisplayName="This is the SECOND host">
            <local:AnTriggerHost.Child>
              <ActivityAction>
                <WriteLine Text="you won't see me" />
              </ActivityAction>
            </local:AnTriggerHost.Child>
            <local:AnTriggerHost.Condition>
              <ActivityFunc x:TypeArguments="x:Boolean">
                <local:AnTrigger DisplayName="I return false guize" ResultToSet="False" />
              </ActivityFunc>
            </local:AnTriggerHost.Condition>
          </local:AnTriggerHost>
        </Sequence>
      </ActivityAction>
    </local:AnTriggerHost.Child>
    <local:AnTriggerHost.Condition>
      <ActivityFunc x:TypeArguments="x:Boolean">
        <local:AnTrigger DisplayName="I return true!" ResultToSet="True" />
      </ActivityFunc>
    </local:AnTriggerHost.Condition>
  </local:AnTriggerHost>

Your issue doesn't lie in the activities, it lies in how you're using them. You're assuming your test rig is correct when it isn't.

Will