//====================================================== // Events //====================================================== //====================================================== // Private methods //====================================================== /// <summary> /// Assigns values to all variables of type <see cref="ExitPoint"/> marked with the <see cref="ExitPointAttribute"/> in the current instance. /// </summary> private void PopulateExitPoints() { var memberInfoTuples = GetType() .GetMembers(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance) .Select(mi => (mi, attr: mi.GetCustomAttribute <ExitPointAttribute>())) .Where(tuple => tuple.attr != null); foreach (var(memberInfo, attribute) in memberInfoTuples) { var type = Util.GetMemberInfoVariableType(memberInfo); if (type == null) { continue; } if (!(type.IsAssignableFrom(typeof(ExitPoint)))) { continue; } var exitPoint = new ExitPoint() { Definition = new ExitPointDefinition() { IsError = attribute.IsError, Name = attribute.Name ?? memberInfo.Name } }; Util.SetMemberValue(this, memberInfo, exitPoint); } }
/// <summary> /// Finds the next steps from a given step in the process. /// </summary> /// <param name="source">The source step from which edges are searched.</param> /// <param name="exit">The exit from which the edge should start.</param> /// <returns>A possibly empty list of states which follow in the automaton based on the defined <see cref="Edges"/>.</returns> public IEnumerable <ProcessStep> FindNextSteps(ProcessStep source, ExitPoint exit) { if (exit == null) { throw new ArgumentNullException(nameof(exit)); } return(Edges .Where(e => e.Source == source && e.SourceExit == exit.Definition) .Select(e => e.Destination)); }