/// <summary> /// Creates an <see cref="IEnumerable{T}" /> from an <see cref="IMMPxTransition" /> /// </summary> /// <param name="source">An <see cref="IMMPxTransition" /> to create an <see cref="IEnumerable{T}" /> from.</param> /// <returns>An <see cref="IEnumerable{T}" /> that contains the fields from the input source.</returns> public static IEnumerable <IMMPxTransition> AsEnumerable(this IMMEnumPxTransition source) { if (source != null) { source.Reset(); IMMPxTransition transition = source.Next(); while (transition != null) { yield return(transition); transition = source.Next(); } } }
/// <summary> /// Determines if a transition exists between the <paramref name="fromState" /> and /// the <paramref name="toState" /> states for the specified <paramref name="user" />. /// </summary> /// <param name="source">The transitions.</param> /// <param name="user">The user.</param> /// <param name="fromState">The From state.</param> /// <param name="toState">The To state.</param> /// <returns> /// Returns a <see cref="bool" /> representing <c>true</c> if there exists a transition; otherwise, <c>false</c>. /// </returns> /// <exception cref="ArgumentNullException"> /// user /// or /// fromState /// or /// toState /// </exception> public static bool IsValidTransition(this IMMEnumPxTransition source, IMMPxUser user, IMMPxState fromState, IMMPxState toState) { if (source == null) { return(false); } if (user == null) { throw new ArgumentNullException("user"); } if (fromState == null) { throw new ArgumentNullException("fromState"); } if (toState == null) { throw new ArgumentNullException("toState"); } return(source.AsEnumerable().Any(transition => transition.IsValidTransition(user, fromState, toState))); }