WorkflowItemPresenter 内容在构建时消失

发布于 2024-09-27 07:33:31 字数 3198 浏览 1 评论 0原文

大家好,
在我的自定义活动中,当我将一个活动放入 WorkflowItemPresenter 中,保存并编译时,我的活动突然消失,而且我不知道为什么。我可能在某个地方犯了一些菜鸟错误,但是我没有看到它。我回去确保我的代码符合要求,然后删除并重新添加包含自定义活动的程序集,以防它可能只是侥幸。之后,当我尝试从引用我的自定义活动的项目进行编译时。它运行但抛出一个 ArgumentNullException。我尝试过向它传递布尔值、条件语句和其他任何东西,这将导致所有结果都以相同的结果结束。对于在这种情况下尝试的故障排除想法有什么建议或明显缺少的东西吗?

这是我对我的情况的参考ActivityFunc;条件

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


这是我对条件返回 true 后要安排的子项的引用public ActivityAction Child

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


这是我的自定义活动

[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>
    /// <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);
        }
    }
}

}

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>
    /// <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);
        }
    }
}

}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

ぶ宁プ宁ぶ 2024-10-04 07:33:31

和我有相同IP的人你好。

ModelItem.Condition 为空。因此,您的绑定失败了,但没有大张旗鼓,这使得这种情况很难弄清楚。

您需要实现 IActivityTemplateFactory 并在 Create 方法中配置您的活动:

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

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
    };
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文