开发者

WorkflowItemPresenter contents disappear on build

Ello all,

In my custom activity, when I drop an activity into the WorkflowItemPresenter, save and compile, my activity suddenly disappears and I have no freakin clue why. I'm probably making some noob mistake somewhere but, I'm not seeing it. I've gone back and made sure my code complies fine and deleted and re-added my assembly containing the custom activity on the off chance it might just be a fluke. After which when I attempt to compile from the project referencing my custom activity. It runs but throws an ArgumentNullException. I've tried passing it bools, conditionals and just about anthing else it would take all ending with the same result. Any suggestions on troubleshooting ideas to try in this case or obvious stuff missing?

Here is my reference to my condition ActivityFunc <bool> Condition.

<sap:WorkflowItemPresenter
                        HintText="Add Trigger conditional activities here"
                        Item="{Binding Path=ModelItem.Condition.Handler}" 
                        Height="40"
                        />

Here is my reference to the child I want to schedule after the condition returns true public ActivityAction Child.

<sap:WorkflowItemPresenter
                        HintText="Add activies that happen on trigger firing"
                        Item="{Binding Path=ModelItem.Child.Handler}" 
                        Height="40"/>

Here is my Custom activity

[Designer(typeof(TriggerDesigner)),
Description("Creates a Trigger for use by trigger conditionals"),    ToolboxCategory(ToolboxCategoryAttribute.Trigger),
ToolboxBitmap(typeof(Shaolin.Activities.ToolboxIconAttribute), "ToolboxIcons.CreateImportContext")]
public sealed class Trigger : NativeActivity
{
    /// <summary>
    /// The initial Condition that determines if the trigger should be scheduled
    /// </summary>
    /// <value>The condition.</value>
    public ActivityFunc<bool> Condition { get; set; }

    /// <summary>
    /// The resulting action that is scheduled if the Condition is true
    /// </summary>
    /// <value>The child.</value>
    public ActivityAction Child { get; set; }

    /// <summary>
    /// Gets or sets the value holding whether or not the trigger matches the condition
    /// </summary>
    /// <value>The type of the match.</value>
    public MatchType MatchType{ get; set; }

    /// <summary>
    /// Perform evaluation of Condition; if is true then schedules Child
    /// </summary>
    /// <param name="context">The execution context in which the activity executes.</param>
    protected override void Execute(NativeActivityContext context)
    {
        context.ScheduleFunc<bool>(this.Condition, new CompletionCallback<bool>(OnConditionComplete));
    }

    /// <summary>
    /// Called from Execute when Condition evaluates to true.
    /// </summary>
    /// <param name="context">The context.</param>
    /// &l开发者_如何学Got;param name="instance">The instance.</param>
    /// <param name="result">if set to <c>true</c> [result].</param>
    public void OnConditionComplete(NativeActivityContext context, ActivityInstance instance, bool result)
    {
        //check if Condition evaluation returns true
        if (result) 
        {
            //If so then schedule child Activity
            context.ScheduleAction(Child);
        }
    }
}

}


Hello person with the same IP as me.

ModelItem.Condition is null. Your binding fails, therefore, but with little fanfare which makes this situation hard to figure out.

You need to implement IActivityTemplateFactory and configure your activity in the Create method:

Activity IActivityTemplateFactory.Create(System.Windows.DependencyObject target)
{
    return new Trigger 
    {
        DisplayName = "lol trigger",
        Condition = new ActivityFunc<bool>(),
        Child = new ActivityAction(),
        MatchType = MatchType.Lol
    };
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜