代码之家  ›  专栏  ›  技术社区  ›  Terrance

WorkflowItemPresenter内容在生成时消失

  •  0
  • Terrance  · 技术社区  · 14 年前

    所有的,
    在自定义活动中,当我将活动放入 WorkflowItemPresenter , 保存编译 ,我的活动突然 消失 我也不知道为什么。我可能在某个地方犯了点小错误,但我看不到。我已经返回并确保我的代码符合要求,删除并重新添加了包含自定义活动的程序集,这可能只是个侥幸。之后,当我尝试从引用自定义活动的项目编译时。它跑了,但却丢了一个 ArgumentNullException . 我试过传递bools,conditionals,或者只是选择其他,结果都是一样的。在这种情况下,有没有任何关于故障排除的建议或明显的东西丢失?

    这是我的病情参考资料 ActivityFunc <bool> Condition .

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

    }

    1 回复  |  直到 14 年前
        1
  •  2
  •   Will    14 年前

    你好,和我拥有相同IP的人。

    ModelItem.Condition为空。因此,您的绑定失败了,但几乎没有什么鼓吹,这使得这种情况很难解决。

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

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