Esempio n. 1
0
        public void Null_argument_tests()
        {
            IChildWorkflowItem childWorkflowItem = null;

            Assert.Throws <ArgumentNullException>(() => childWorkflowItem.Result());
            Assert.Throws <ArgumentNullException>(() => childWorkflowItem.Result <int>());
            Assert.Throws <ArgumentNullException>(() => childWorkflowItem.HasCompleted());
            Assert.Throws <ArgumentNullException>(() => childWorkflowItem.HasFailed());
            Assert.Throws <ArgumentNullException>(() => childWorkflowItem.HasTimedout());
        }
        /// <summary>
        /// Access completed result of child workflow as dynamic object. If completed result is JSON object then you can directly access its properties.
        /// Throws exception when last event is not <see cref="ChildWorkflowCompletedEvent"/>.
        /// </summary>
        /// <param name="item"></param>
        /// <returns></returns>
        public static dynamic Result(this IChildWorkflowItem item)
        {
            Ensure.NotNull(item, nameof(item));
            var completedEvent = item.LastEvent() as ChildWorkflowCompletedEvent;

            if (completedEvent == null)
            {
                throw new InvalidOperationException(Resources.ChildWorkflow_result_can_not_be_accessed);
            }
            return(completedEvent.Result());
        }
 /// <summary>
 /// Retruns the <see cref="ChildWorkflowFailedEvent"/> and if it is the last event, otherwise null is returned.
 /// </summary>
 /// <param name="item"></param>
 /// <returns></returns>
 public static ChildWorkflowFailedEvent LastFailedEvent(this IChildWorkflowItem item)
 {
     Ensure.NotNull(item, nameof(item));
     return(item.LastEvent() as ChildWorkflowFailedEvent);
 }
 /// <summary>
 /// Returns true if last event of child workflow is <see cref="ChildWorkflowCancelledEvent"/>
 /// </summary>
 /// <param name="item"></param>
 /// <returns></returns>
 public static bool HasCancelled(this IChildWorkflowItem item)
 {
     Ensure.NotNull(item, nameof(item));
     return(item.LastEvent() is ChildWorkflowCancelledEvent);
 }
 /// <summary>
 /// Returns true if last event of child workflow is <see cref="ChildWorkflowTerminatedEvent"/>
 /// </summary>
 /// <param name="item"></param>
 /// <returns></returns>
 public static bool HasTerminated(this IChildWorkflowItem item) => item.LastTerminatedEvent() != null;
 /// <summary>
 /// Returns true if the last event of child workflow is <see cref="ChildWorkflowTimedoutEvent"/>.
 /// </summary>
 /// <param name="item"></param>
 /// <returns></returns>
 public static bool HasTimedout(this IChildWorkflowItem item) => item.LastTimedoutEvent() != null;
 /// <summary>
 /// Returns true if the last event of child workflow is <see cref="ChildWorkflowFailedEvent"/>.
 /// </summary>
 /// <param name="item"></param>
 /// <returns></returns>
 public static bool HasFailed(this IChildWorkflowItem item) => item.LastFailedEvent() != null;
 /// <summary>
 /// Returns true if the last event of child workflow is <see cref="ChildWorkflowCompletedEvent"/>.
 /// </summary>
 /// <param name="item"></param>
 /// <returns></returns>
 public static bool HasCompleted(this IChildWorkflowItem item) => item.LastCompletedEvent() != null;
Esempio n. 9
0
        private string WorkflowInput(IChildWorkflowItem item)
        {
            var lastEvent = item.LastEvent() as ChildWorkflowEvent;

            return(lastEvent != null ? lastEvent.Input : StartedEvent.Input);
        }
Esempio n. 10
0
 /// <summary>
 /// Send signal to child workflow.
 /// </summary>
 /// <param name="childWorkflow"></param>
 /// <returns></returns>
 public WorkflowAction ForChildWorkflow(IChildWorkflowItem childWorkflow)
 {
     Ensure.NotNull(childWorkflow, nameof(childWorkflow));
     return(ForChildWorkflow(childWorkflow.Name, childWorkflow.Version, childWorkflow.PositionalName));
 }