/// <summary>
        /// Decoration that flags a task as being asynchronous and provides the conditions needed to trigger completion and error.
        /// Automatically decorates with TriggerConditions.
        /// </summary>
        /// <param name="task"></param>
        /// <returns></returns>
        public static IAsynchronousDecoration IsAsynchronous(this ITask task, ICondition markCompleteCondition, ICondition markErrorCondition)
        {
            Condition.Requires(task).IsNotNull();
            var rv = task.As <AsynchronousDecoration>();

            if (rv == null)
            {
                rv = new AsynchronousDecoration(task, markCompleteCondition, markErrorCondition);
            }
            return(rv);
        }
        /// <summary>
        /// indicates the task is synchronous
        /// </summary>
        /// <param name="task"></param>
        /// <returns></returns>
        public static ISynchronousDecoration IsSynchronous(this ITask task)
        {
            Condition.Requires(task).IsNotNull();
            var rv = task.As <SynchronousDecoration>();

            if (rv == null)
            {
                rv = new SynchronousDecoration(task);
            }
            return(rv);
        }
示例#3
0
        /// <summary>
        /// Decorates with triggers (as ICondition) for task state transitions.  Does not change the behaviour at all, just adds new behaviour
        /// in CheckTriggers that will examine the trigger conditions and perform a state transition method if the condition is true.
        /// </summary>
        /// <param name="task"></param>
        /// <returns></returns>
        public static IHasConditionalTaskTriggers Triggered(this ITask task)
        {
            Condition.Requires(task).IsNotNull();

            var rv = task.As <ConditionalTriggerDecoration>();

            if (rv == null)
            {
                rv = new ConditionalTriggerDecoration(task);
            }

            return(rv);
        }
示例#4
0
        /// <summary>
        /// decorate a task indicating it needs the provided tasks to complete before starting.
        /// Automatically decorates with ConditionalTriggers to accomplish this.
        /// </summary>
        /// <param name="task"></param>
        /// <returns></returns>
        /// <remarks>
        /// There can only be one dependency decoration per task layer cake
        /// </remarks>
        public static IHasTaskDependency DependsOn(this ITask task, params string[] prerequisiteTaskIds)
        {
            Condition.Requires(task).IsNotNull();

            //we can only have one dependency decoration per cake, so go grab that one and update it
            if (task.HasDecoration <DependencyDecoration>())
            {
                var dec = task.As <DependencyDecoration>();
                dec.Dependency.Prerequisites.AddRange(prerequisiteTaskIds);
                return(dec);
            }

            return(new DependencyDecoration(task, prerequisiteTaskIds.ToList()));
        }
示例#5
0
        public static ITask DoesNotDependOn(this ITask task, params string[] prerequisiteTaskIds)
        {
            Condition.Requires(task).IsNotNull();
            if (task.HasDecoration <DependencyDecoration>())
            {
                var dec = task.As <DependencyDecoration>();
                prerequisiteTaskIds.WithEach(pre =>
                {
                    dec.Dependency.Prerequisites.Remove(pre);
                });

                return(dec);
            }

            return(task);
        }